#include "board_xc151.h"

//00-AE          01-AF        02-BLC        03-LENC            04-AWB        05-HDR        06-RAW_Gamma        07-RGB_Gamma
//08-YUV_Gamma   09-CMX       10-NR3D       11-SNR             11-YNR        13-CIP        14-YDE              15-CADJ
//16-IQ_Oneself  17-ISP_OSD   18-IQ_switch  19-car_back_line   20-Mjpeg      21-Manual_3A  22-Top_enable

///////////////////////////////////////////////////////////////////////////////
//Function : AE
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
//hdr_mode: 0:disable 2:2expo hdr 3:expo hdr
void  AE_cfg (unsigned char hdr_mode,
              unsigned short sensor_i2c_id,
              unsigned short sensor_i2c_mode,
              unsigned short type_gain,
              unsigned short type_exp,
              unsigned short gain_shift,
              unsigned short exp_shift,              
              unsigned short sensor_gain_addr[4],
              unsigned short sensor_gain_mask[4],
              unsigned short sensor_exp_addr[4],
              unsigned short sensor_exp_mask[4]
              )
{
	WriteReg8(0x80305409, 0x00);//newmode_CurAvg
	fprintf(setting,"//sensor_info\n");
	WriteReg8(0x200000fe, sensor_i2c_id);//sensor_id
	WriteReg8(0x200000ff, sensor_i2c_mode&0xff);//i2c_mode
	WriteReg8(0x20000100, type_gain&0xff);//type_gain
	WriteReg8(0x20000101, type_exp&0xff);//type_exp
	WriteReg8(0x20000104, 0x00);//sensor_gain_mode
	WriteReg8(0x200000c8, exp_shift&0xff);//exp_shift
	WriteReg8(0x200000c9, gain_shift&0xff);//gain_shift
	
	if (type_exp ==0) {
		WriteReg8(0x20000108, sensor_exp_addr[0]&0xff);//exp_addr
		WriteReg8(0x20000109, (sensor_exp_addr[0]>>8)&0xff);
		WriteReg8(0x2000010a, sensor_exp_addr[1]&0xff);
		WriteReg8(0x2000010b, (sensor_exp_addr[1]>>8)&0xff);
		WriteReg8(0x2000010c, sensor_exp_addr[2]&0xff);
		WriteReg8(0x2000010d, (sensor_exp_addr[2]>>8)&0xff);
		WriteReg8(0x2000010e, sensor_exp_addr[3]&0xff);
		WriteReg8(0x2000010f, (sensor_exp_addr[3]>>8)&0xff);
		
		WriteReg8(0x20000110, sensor_exp_mask[0]&0xff);//exp_mask
		WriteReg8(0x20000111, (sensor_exp_mask[0]>>8)&0xff);
		WriteReg8(0x20000112, sensor_exp_mask[1]&0xff);
		WriteReg8(0x20000113, (sensor_exp_mask[1]>>8)&0xff);
		WriteReg8(0x20000114, sensor_exp_mask[2]&0xff);
		WriteReg8(0x20000115, (sensor_exp_mask[2]>>8)&0xff);
		WriteReg8(0x20000116, sensor_exp_mask[3]&0xff);
		WriteReg8(0x20000117, (sensor_exp_mask[3]>>8)&0xff);
	}
	if (type_gain ==0) {
		WriteReg8(0x20000128, sensor_gain_addr[0]&0xff);//gain_addr
		WriteReg8(0x20000129, (sensor_gain_addr[0]>>8)&0xff);
		WriteReg8(0x2000012a, sensor_gain_addr[1]&0xff);
		WriteReg8(0x2000012b, (sensor_gain_addr[1]>>8)&0xff);
		WriteReg8(0x2000012c, sensor_gain_addr[2]&0xff);
		WriteReg8(0x2000012d, (sensor_gain_addr[2]>>8)&0xff);
		WriteReg8(0x2000012e, sensor_gain_addr[3]&0xff);
		WriteReg8(0x2000012f, (sensor_gain_addr[3]>>8)&0xff);
		
		WriteReg8(0x20000130, sensor_gain_mask[0]&0xff);//gain_mask
		WriteReg8(0x20000131, (sensor_gain_mask[0]>>8)&0xff);
		WriteReg8(0x20000132, sensor_gain_mask[1]&0xff);
		WriteReg8(0x20000133, (sensor_gain_mask[1]>>8)&0xff);
		WriteReg8(0x20000134, sensor_gain_mask[2]&0xff);
		WriteReg8(0x20000135, (sensor_gain_mask[2]>>8)&0xff);
		WriteReg8(0x20000136, sensor_gain_mask[3]&0xff);
		WriteReg8(0x20000137, (sensor_gain_mask[3]>>8)&0xff);
	}
	
	fprintf(setting,"\n");
	fprintf(setting,"//Area_weight\n");
	WriteReg8(0x20000078, 0x02);
	WriteReg8(0x20000079, 0x02);
	WriteReg8(0x2000007a, 0x02);
	WriteReg8(0x2000007b, 0x02);
	WriteReg8(0x2000007c, 0x02);
	WriteReg8(0x2000007d, 0x02);
	WriteReg8(0x2000007e, 0x02);
	WriteReg8(0x2000007f, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x20000080, 0x02);
	WriteReg8(0x20000081, 0x02);
	WriteReg8(0x20000082, 0x04);
	WriteReg8(0x20000083, 0x04);
	WriteReg8(0x20000084, 0x04);
	WriteReg8(0x20000085, 0x04);
	WriteReg8(0x20000086, 0x02);
	WriteReg8(0x20000087, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x20000088, 0x02);
	WriteReg8(0x20000089, 0x02);
	WriteReg8(0x2000008a, 0x04);
	WriteReg8(0x2000008b, 0x04);
	WriteReg8(0x2000008c, 0x04);
	WriteReg8(0x2000008d, 0x04);
	WriteReg8(0x2000008e, 0x02);
	WriteReg8(0x2000008f, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x20000090, 0x02);
	WriteReg8(0x20000091, 0x02);
	WriteReg8(0x20000092, 0x04);
	WriteReg8(0x20000093, 0x04);
	WriteReg8(0x20000094, 0x04);
	WriteReg8(0x20000095, 0x04);
	WriteReg8(0x20000096, 0x02);
	WriteReg8(0x20000097, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x20000098, 0x02);
	WriteReg8(0x20000099, 0x02);
	WriteReg8(0x2000009a, 0x04);
	WriteReg8(0x2000009b, 0x04);
	WriteReg8(0x2000009c, 0x04);
	WriteReg8(0x2000009d, 0x04);
	WriteReg8(0x2000009e, 0x02);
	WriteReg8(0x2000009f, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x200000a0, 0x02);
	WriteReg8(0x200000a1, 0x02);
	WriteReg8(0x200000a2, 0x04);
	WriteReg8(0x200000a3, 0x04);
	WriteReg8(0x200000a4, 0x04);
	WriteReg8(0x200000a5, 0x04);
	WriteReg8(0x200000a6, 0x02);
	WriteReg8(0x200000a7, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x200000a8, 0x02);
	WriteReg8(0x200000a9, 0x02);
	WriteReg8(0x200000aa, 0x02);
	WriteReg8(0x200000ab, 0x02);
	WriteReg8(0x200000ac, 0x02);
	WriteReg8(0x200000ad, 0x02);
	WriteReg8(0x200000ae, 0x02);
	WriteReg8(0x200000af, 0x02);
	fprintf(setting,"\n");	
	WriteReg8(0x200000b0, 0x02);
	WriteReg8(0x200000b1, 0x02);
	WriteReg8(0x200000b2, 0x02);
	WriteReg8(0x200000b3, 0x02);
	WriteReg8(0x200000b4, 0x02);
	WriteReg8(0x200000b5, 0x02);
	WriteReg8(0x200000b6, 0x02);
	WriteReg8(0x200000b7, 0x02);
	fprintf(setting,"\n");
	fprintf(setting,"//Attention\n");
	WriteReg8(0x200000b8, 0x00);
	WriteReg8(0x200000b9, 0x07);
	WriteReg8(0x200000ba, 0x39);
	WriteReg8(0x200000bb, 0xce);
	WriteReg8(0x200000bc, 0xff);
	WriteReg8(0x200000bd, 0xff);
	WriteReg8(0x200000be, 0xff);
	WriteReg8(0x200000bf, 0xff);
	
	WriteReg8(0x20000077, 0x01);//nWinFresh//don't_modify
	fprintf(setting,"\n");
	fprintf(setting,"//AE_base0\n");	
	WriteReg8(0x20000068, 0x00);//AEC_mode
	WriteReg8(0x20000069, 0x01);//bAEAGForceWrite
	fprintf(setting,"\n");
	if (hdr_mode ==0) {
		WriteReg8(0x20000246,0x00);//nHDR_Mode0:non-HDRmodeAEC1:ManualAEC2:HDRAEC
	}
	else {
		WriteReg8(0x20000246,0x02);//nHDR_Mode0:non-HDRmodeAEC1:ManualAEC2:HDRAEC
	}

	if (hdr_mode !=0) {
		WriteReg8(0x20000247, 0x03);//nHDR_SyncMode_S1:sync_none2:sync_exp3:sync_gain
		WriteReg8(0x200002f4, 0x01);//hdr_ae_same_gain_en
		WriteReg8(0x20000321, 0x01);//hdr_ae_trigger_timer_en
		WriteReg8(0x20000322, 0x70);//[7:0]hdr_ae_trigger_timer_th
		WriteReg8(0x20000323, 0x17);//[15:8]hdr_ae_trigger_timer_th
	}
	fprintf(setting,"\n");
	WriteReg8(0x200000c0, 0xf0);//nTargetY[7:0]
	WriteReg8(0x200000c1, 0x01);//nTargetY[15:8]
	fprintf(setting,"\n");
	WriteReg8(0x200000d2, 0xff);//max_gain
	WriteReg8(0x200000d3, 0x04);
	WriteReg8(0x200000d4, 0x24);//min_gain
	WriteReg8(0x200000d5, 0x00);
	WriteReg8(0x200000d6, 0x00);//max_sensor_gain
	WriteReg8(0x200000d7, 0x10);
	
	if (hdr_mode !=0) {
		WriteReg8(0x20000258, 0x00);//nMaxGain_S
		WriteReg8(0x20000259, 0x10);
		WriteReg8(0x2000025a, 0x20);//nMinGain_S
		WriteReg8(0x2000025b, 0x00);
	}
	if (hdr_mode ==3) {
		WriteReg8(0x20000264, 0x00);//max_gain_VS
		WriteReg8(0x20000265, 0x08);
		WriteReg8(0x20000266, 0x20);//min_gain_VS
		WriteReg8(0x20000267, 0x00);		
	}
	
	fprintf(setting,"\n");
	if (hdr_mode ==0) {
		WriteReg8(0x20000272,0x01);//nCalcRatio_JumpEn
	}
	else {
		WriteReg8(0x20000273,0x01);//nCalcRatioHDR_JumpEn
	}

	if (hdr_mode !=0) {		
		WriteReg8(0x2000024a, 0x40);//nHDR_ChannelRatio_S[7:0]
		WriteReg8(0x2000024b, 0x00);//nHDR_ChannelRatio_S[15:8]
		WriteReg8(0x2000024c, 0x40);//nHDR_ChannelRatio_VS[7:0]
		WriteReg8(0x2000024d, 0x00);//nHDR_ChannelRatio_VS[15:8]
		
		WriteReg8(0x20000274, 0x00);//nP2_Enable_L
		WriteReg8(0x20000275, 0x00);//nP2_Enable_S
		WriteReg8(0x20000276, 0x00);//nP3_Enable_L
		WriteReg8(0x20000277, 0x00);//nP3_Enable_S
		
		WriteReg8(0x2000027c, 0x40);//nP1_AffectRatio[7:0]
		WriteReg8(0x2000027d, 0x00);//nP1_AffectRatio[15:8]
		WriteReg8(0x2000027e, 0x00);//nP1_MaxLimit_L[7:0]
		WriteReg8(0x2000027f, 0x10);//nP1_MaxLimit_L[15:8]
		WriteReg8(0x20000280, 0x80);//nP1_TargetY_L[7:0]
		WriteReg8(0x20000281, 0x01);//nP1_TargetY_L[15:8]
		WriteReg8(0x20000282, 0x80);//nP1_TargetY_S[7:0]
		WriteReg8(0x20000283, 0x00);//nP1_TargetY_S[15:8]
		WriteReg8(0x20000284, 0x40);//nP1_AffectRatio_S[7:0]
		WriteReg8(0x20000285, 0x00);//nP1_AffectRatio_S[15:8]
		WriteReg8(0x20000286, 0x00);//nP1_MaxLimit_S[7:0]
		WriteReg8(0x20000287, 0x10);//nP1_MaxLimit_S[15:8]
		
		WriteReg8(0x20000288, 0x01);//nP2_UsedCnt_L[7:0]
		WriteReg8(0x20000289, 0x01);//nP2_UsedCnt_S[7:0]
		WriteReg8(0x2000028c, 0x40);//nP2_BrightenAvg_S[7:0]
		WriteReg8(0x2000028d, 0x00);//nP2_BrightenAvg_S[15:8]
		WriteReg8(0x2000028e, 0x40);//nP2_AffectRatio_S[7:0]
		WriteReg8(0x2000028f, 0x00);//nP2_AffectRatio_S[15:8]
		WriteReg8(0x20000290, 0x00);//nP2_MaxLimit_S[7:0]
		WriteReg8(0x20000291, 0x10);//nP2_MaxLimit_S[15:8]
	}
	
	fprintf(setting,"\n");
	fprintf(setting,"//AE_speed\n");
	WriteReg8(0x20000138, 0x00);//exp_delay
	WriteReg8(0x20000139, 0x00);//gain_delay
	WriteReg8(0x20000024, 0x02);//exp_mode
	WriteReg8(0x20000025, 0x02);//gain_mode
	
	WriteReg8(0x200000dc, 0x01);//nDelayFrame
	WriteReg8(0x200000dd, 0x0c);//nJudgement2Stable
	
	WriteReg8(0x200000de, 0x28);//global_all_diff_thr
	WriteReg8(0x200000df, 0x00);
	
	WriteReg8(0x200000e6, 0x60);//jump_luma_diff
	WriteReg8(0x200000e7, 0x00);
	WriteReg8(0x200000e8, 0x80);//luma_diff_thr_low
	WriteReg8(0x200000e9, 0x00);
	WriteReg8(0x200000ea, 0x00);//luma_diff_thr_high
	WriteReg8(0x200000eb, 0x03);
	WriteReg8(0x200000ec, 0x48);//jump_thr
	WriteReg8(0x200000ed, 0x00);
	WriteReg8(0x200000ee, 0x80);//jump_mutiple
	WriteReg8(0x200000ef, 0x00);
	WriteReg8(0x200000f0, 0x80);//max_jump_ratio
	WriteReg8(0x200000f1, 0x00);
	WriteReg8(0x200000f2, 0x02);//max_jump_cnt
	
	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		WriteReg8(0x2000006c, 0x40);//detect_thr
		WriteReg8(0x2000006d, 0x00);
		WriteReg8(0x2000006e, 0x40);//detect_ratio_low
		WriteReg8(0x2000006f, 0x00);
		WriteReg8(0x20000070, 0x80);//detect_ratio_high
		WriteReg8(0x20000071, 0x00);
		WriteReg8(0x20000072, 0x06);//detect_Continuous_cnt
		WriteReg8(0x20000073, 0x00);
		WriteReg8(0x20000074, 0x00);//detect_targetChange_thr
		WriteReg8(0x20000075, 0x00);
	}
	fprintf(setting,"\n");
	WriteReg8(0x2000013a, 0x00);//magnitude_en
	WriteReg8(0x2000013b, 0x04);//magnitude_offset
	WriteReg8(0x2000013c, 0x00);//magnitude_min
	WriteReg8(0x2000013d, 0x10);//magnitude_max
	
	WriteReg8(0x2000017c, 0x01);//mutiple_frame
	WriteReg8(0x2000017d, 0x00);//active_frame
	fprintf(setting,"\n");	
	WriteReg8(0x2000023f, 0x01);//calcAvg_Newmode_en
	WriteReg8(0x20000240, 0x00);//AvgCalc_startBlk
	WriteReg8(0x20000241, 0x40);//AvgCalc_Blknum
	WriteReg8(0x20000242, 0x00);//AvgIsqrt_en
	
	fprintf(setting,"\n");	
	fprintf(setting,"//AE_speed_table\n");
	fprintf(setting,"//if diff < 0 //diff = (meanY - targetY)\n");
	WriteReg8(0x2000017e, 0x01);//AE_speed_table_D2B
	WriteReg8(0x2000017f, 0x01);
	WriteReg8(0x20000180, 0x01);
	WriteReg8(0x20000181, 0x01);
	WriteReg8(0x20000182, 0x02);
	WriteReg8(0x20000183, 0x02);
	WriteReg8(0x20000184, 0x02);
	WriteReg8(0x20000185, 0x02);//diff_0x00~0x80
	fprintf(setting,"\n");	
	WriteReg8(0x20000186, 0x04);
	WriteReg8(0x20000187, 0x04);
	WriteReg8(0x20000188, 0x04);
	WriteReg8(0x20000189, 0x04);
	WriteReg8(0x2000018a, 0x06);
	WriteReg8(0x2000018b, 0x06);
	WriteReg8(0x2000018c, 0x06);
	WriteReg8(0x2000018d, 0x06);//diff_0x90~0x100
	fprintf(setting,"\n");	
	WriteReg8(0x2000018e, 0x08);
	WriteReg8(0x2000018f, 0x08);
	WriteReg8(0x20000190, 0x08);
	WriteReg8(0x20000191, 0x08);
	WriteReg8(0x20000192, 0x0a);
	WriteReg8(0x20000193, 0x0a);
	WriteReg8(0x20000194, 0x0a);
	WriteReg8(0x20000195, 0x0a);//diff_0x110~0x180
	fprintf(setting,"\n");	
	WriteReg8(0x20000196, 0x0c);
	WriteReg8(0x20000197, 0x0c);
	WriteReg8(0x20000198, 0x0c);
	WriteReg8(0x20000199, 0x0c);
	WriteReg8(0x2000019a, 0x0e);
	WriteReg8(0x2000019b, 0x0e);
	WriteReg8(0x2000019c, 0x0e);
	WriteReg8(0x2000019d, 0x0e);//diff_0x190~0x200
	fprintf(setting,"\n");	
	WriteReg8(0x2000019e, 0x10);
	WriteReg8(0x2000019f, 0x10);
	WriteReg8(0x200001a0, 0x10);
	WriteReg8(0x200001a1, 0x10);
	WriteReg8(0x200001a2, 0x14);
	WriteReg8(0x200001a3, 0x14);
	WriteReg8(0x200001a4, 0x14);
	WriteReg8(0x200001a5, 0x14);//diff_0x210~0x280
	fprintf(setting,"\n");	
	WriteReg8(0x200001a6, 0x16);
	WriteReg8(0x200001a7, 0x16);
	WriteReg8(0x200001a8, 0x16);
	WriteReg8(0x200001a9, 0x16);
	WriteReg8(0x200001aa, 0x16);
	WriteReg8(0x200001ab, 0x16);
	WriteReg8(0x200001ac, 0x16);
	WriteReg8(0x200001ad, 0x16);
	fprintf(setting,"\n");	
	WriteReg8(0x200001ae, 0x18);
	WriteReg8(0x200001af, 0x18);
	WriteReg8(0x200001b0, 0x18);
	WriteReg8(0x200001b1, 0x18);
	WriteReg8(0x200001b2, 0x18);
	WriteReg8(0x200001b3, 0x18);
	WriteReg8(0x200001b4, 0x18);
	WriteReg8(0x200001b5, 0x18);
	fprintf(setting,"\n");	
	WriteReg8(0x200001b6, 0x1a);
	WriteReg8(0x200001b7, 0x1a);
	WriteReg8(0x200001b8, 0x1a);
	WriteReg8(0x200001b9, 0x1a);
	WriteReg8(0x200001ba, 0x1a);
	WriteReg8(0x200001bb, 0x1a);
	WriteReg8(0x200001bc, 0x1a);
	WriteReg8(0x200001bd, 0x1a);
	
	fprintf(setting,"\n");
	fprintf(setting,"//if diff > 0 //diff = (meanY - targetY)\n");
	WriteReg8(0x200001be, 0x01);//AE_speed_table_B2D
	WriteReg8(0x200001bf, 0x01);
	WriteReg8(0x200001c0, 0x01);
	WriteReg8(0x200001c1, 0x01);
	WriteReg8(0x200001c2, 0x02);
	WriteReg8(0x200001c3, 0x02);
	WriteReg8(0x200001c4, 0x02);
	WriteReg8(0x200001c5, 0x02);//diff_0x00~0x80
	fprintf(setting,"\n");	
	WriteReg8(0x200001c6, 0x04);
	WriteReg8(0x200001c7, 0x04);
	WriteReg8(0x200001c8, 0x04);
	WriteReg8(0x200001c9, 0x04);
	WriteReg8(0x200001ca, 0x06);
	WriteReg8(0x200001cb, 0x06);
	WriteReg8(0x200001cc, 0x06);
	WriteReg8(0x200001cd, 0x06);//diff_0x90~0x100
	fprintf(setting,"\n");	
	WriteReg8(0x200001ce, 0x08);
	WriteReg8(0x200001cf, 0x08);
	WriteReg8(0x200001d0, 0x08);
	WriteReg8(0x200001d1, 0x08);
	WriteReg8(0x200001d2, 0x0a);
	WriteReg8(0x200001d3, 0x0a);
	WriteReg8(0x200001d4, 0x0a);
	WriteReg8(0x200001d5, 0x0a);//diff_0x110~0x180
	fprintf(setting,"\n");	
	WriteReg8(0x200001d6, 0x0c);
	WriteReg8(0x200001d7, 0x0c);
	WriteReg8(0x200001d8, 0x0c);
	WriteReg8(0x200001d9, 0x0c);
	WriteReg8(0x200001da, 0x0e);
	WriteReg8(0x200001db, 0x0e);
	WriteReg8(0x200001dc, 0x0e);
	WriteReg8(0x200001dd, 0x0e);//diff_0x190~0x200
	fprintf(setting,"\n");	
	WriteReg8(0x200001de, 0x10);
	WriteReg8(0x200001df, 0x10);
	WriteReg8(0x200001e0, 0x10);
	WriteReg8(0x200001e1, 0x10);
	WriteReg8(0x200001e2, 0x12);
	WriteReg8(0x200001e3, 0x12);
	WriteReg8(0x200001e4, 0x12);
	WriteReg8(0x200001e5, 0x12);//diff_0x210~0x280
	fprintf(setting,"\n");	
	WriteReg8(0x200001e6, 0x14);
	WriteReg8(0x200001e7, 0x14);
	WriteReg8(0x200001e8, 0x14);
	WriteReg8(0x200001e9, 0x14);
	WriteReg8(0x200001ea, 0x14);
	WriteReg8(0x200001eb, 0x14);
	WriteReg8(0x200001ec, 0x14);
	WriteReg8(0x200001ed, 0x14);
	fprintf(setting,"\n");	
	WriteReg8(0x200001ee, 0x16);
	WriteReg8(0x200001ef, 0x16);
	WriteReg8(0x200001f0, 0x16);
	WriteReg8(0x200001f1, 0x16);
	WriteReg8(0x200001f2, 0x16);
	WriteReg8(0x200001f3, 0x16);
	WriteReg8(0x200001f4, 0x16);
	WriteReg8(0x200001f5, 0x16);
	fprintf(setting,"\n");	
	WriteReg8(0x200001f6, 0x16);
	WriteReg8(0x200001f7, 0x16);
	WriteReg8(0x200001f8, 0x16);
	WriteReg8(0x200001f9, 0x16);
	WriteReg8(0x200001fa, 0x16);
	WriteReg8(0x200001fb, 0x16);
	WriteReg8(0x200001fc, 0x16);
	WriteReg8(0x200001fd, 0x16);
	fprintf(setting,"\n");	
	WriteReg8(0x200002d9, 0x01);//AE_speed_mode_man_en
	WriteReg8(0x200002da, 0x00);//AE_speed_mode_man
	WriteReg8(0x200003fe, 0x01);//hdr_ae_speed_factor_slow_b2d
	WriteReg8(0x200003ff, 0x01);//hdr_ae_speed_factor_slow_d2b
	
	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		WriteReg8(0x2000035a, 0x01);//hdr_ae_adaptive_en
		WriteReg8(0x2000035b, 0x01);//hdr_ae_adaptive_en_hls_l_number
		WriteReg8(0x2000035f, 0x01);//hdr_ae_adaptive_en_hls_l_luma
		WriteReg8(0x20000360, 0x01);//hdr_ae_adaptive_en_hls_s_luma
		WriteReg8(0x20000361, 0x01);//hdr_ae_adaptive_en_hw_gma
		WriteReg8(0x20000362, 0x01);//hdr_ae_adaptive_en_hw_tm
		
		fprintf(setting,"\n");
		WriteReg8(0x20000364, 0x00);//hdr_ae_adaptive_avg_factor
		WriteReg8(0x20000365, 0x01);//hdr_ae_adaptive_avg_factor
		WriteReg8(0x20000366, 0x00);//hdr_ae_adaptive_avg_factor
		WriteReg8(0x20000367, 0x00);//hdr_ae_adaptive_avg_factor
		fprintf(setting,"\n");
		WriteReg8(0x20000368, 0x00);//hdr_ae_adaptive_dr_table[0]
		WriteReg8(0x20000369, 0x10);//hdr_ae_adaptive_dr_table[1]
		WriteReg8(0x2000036a, 0x20);//hdr_ae_adaptive_dr_table[2]
		WriteReg8(0x2000036b, 0x40);//hdr_ae_adaptive_dr_table[3]
		WriteReg8(0x2000036c, 0x60);//hdr_ae_adaptive_dr_table[4]
		WriteReg8(0x2000036d, 0x80);//hdr_ae_adaptive_dr_table[5]
		WriteReg8(0x2000036e, 0xA0);//hdr_ae_adaptive_dr_table[6]
		WriteReg8(0x2000036f, 0xC0);//hdr_ae_adaptive_dr_table[7]
		fprintf(setting,"\n");
		WriteReg8(0x20000370, 0x00);//hdr_ae_adaptive_avg_table[0]
		WriteReg8(0x20000371, 0x10);//hdr_ae_adaptive_avg_table[1]
		WriteReg8(0x20000372, 0x20);//hdr_ae_adaptive_avg_table[2]
		WriteReg8(0x20000373, 0x30);//hdr_ae_adaptive_avg_table[3]
		WriteReg8(0x20000374, 0x40);//hdr_ae_adaptive_avg_table[4]
		WriteReg8(0x20000375, 0x50);//hdr_ae_adaptive_avg_table[5]
		WriteReg8(0x20000376, 0x60);//hdr_ae_adaptive_avg_table[6]
		WriteReg8(0x20000377, 0x70);//hdr_ae_adaptive_avg_table[7]
		fprintf(setting,"\n");
		WriteReg8(0x20000378, 0x10);//hdr_ae_adaptive_hls_l_number[0]
		WriteReg8(0x20000379, 0x14);//hdr_ae_adaptive_hls_l_number[1]
		WriteReg8(0x2000037a, 0x18);//hdr_ae_adaptive_hls_l_number[2]
		WriteReg8(0x2000037b, 0x1a);//hdr_ae_adaptive_hls_l_number[3]
		WriteReg8(0x2000037c, 0x20);//hdr_ae_adaptive_hls_l_number[4]
		WriteReg8(0x2000037d, 0x28);//hdr_ae_adaptive_hls_l_number[5]
		WriteReg8(0x2000037e, 0x30);//hdr_ae_adaptive_hls_l_number[6]
		WriteReg8(0x2000037f, 0x30);//hdr_ae_adaptive_hls_l_number[7]
		fprintf(setting,"\n");
		WriteReg8(0x20000380, 0x40);//hdr_ae_adaptive_hls_l_luma[0]
		WriteReg8(0x20000381, 0x01);//hdr_ae_adaptive_hls_l_luma[0]
		WriteReg8(0x20000382, 0x60);//hdr_ae_adaptive_hls_l_luma[1]
		WriteReg8(0x20000383, 0x01);//hdr_ae_adaptive_hls_l_luma[1]
		WriteReg8(0x20000384, 0x80);//hdr_ae_adaptive_hls_l_luma[2]
		WriteReg8(0x20000385, 0x01);//hdr_ae_adaptive_hls_l_luma[2]
		WriteReg8(0x20000386, 0xa0);//hdr_ae_adaptive_hls_l_luma[3]
		WriteReg8(0x20000387, 0x01);//hdr_ae_adaptive_hls_l_luma[3]
		WriteReg8(0x20000388, 0xb0);//hdr_ae_adaptive_hls_l_luma[4]
		WriteReg8(0x20000389, 0x01);//hdr_ae_adaptive_hls_l_luma[4]
		WriteReg8(0x2000038a, 0xc0);//hdr_ae_adaptive_hls_l_luma[5]
		WriteReg8(0x2000038b, 0x01);//hdr_ae_adaptive_hls_l_luma[5]
		WriteReg8(0x2000038c, 0xd0);//hdr_ae_adaptive_hls_l_luma[6]
		WriteReg8(0x2000038d, 0x01);//hdr_ae_adaptive_hls_l_luma[6]
		WriteReg8(0x2000038e, 0xe0);//hdr_ae_adaptive_hls_l_luma[7]
		WriteReg8(0x2000038f, 0x01);//hdr_ae_adaptive_hls_l_luma[7]
		fprintf(setting,"\n");
		WriteReg8(0x20000390, 0xC8);//hdr_ae_adaptive_hls_s_luma[0]
		WriteReg8(0x20000391, 0x00);//hdr_ae_adaptive_hls_s_luma[0]
		WriteReg8(0x20000392, 0xE8);//hdr_ae_adaptive_hls_s_luma[1]
		WriteReg8(0x20000393, 0x00);//hdr_ae_adaptive_hls_s_luma[1]
		WriteReg8(0x20000394, 0x08);//hdr_ae_adaptive_hls_s_luma[2]
		WriteReg8(0x20000395, 0x01);//hdr_ae_adaptive_hls_s_luma[2]
		WriteReg8(0x20000396, 0x28);//hdr_ae_adaptive_hls_s_luma[3]
		WriteReg8(0x20000397, 0x01);//hdr_ae_adaptive_hls_s_luma[3]
		WriteReg8(0x20000398, 0x48);//hdr_ae_adaptive_hls_s_luma[4]
		WriteReg8(0x20000399, 0x01);//hdr_ae_adaptive_hls_s_luma[4]
		WriteReg8(0x2000039a, 0x68);//hdr_ae_adaptive_hls_s_luma[5]
		WriteReg8(0x2000039b, 0x01);//hdr_ae_adaptive_hls_s_luma[5]
		WriteReg8(0x2000039c, 0x88);//hdr_ae_adaptive_hls_s_luma[6]
		WriteReg8(0x2000039d, 0x01);//hdr_ae_adaptive_hls_s_luma[6]
		WriteReg8(0x2000039e, 0xA8);//hdr_ae_adaptive_hls_s_luma[7]
		WriteReg8(0x2000039f, 0x01);//hdr_ae_adaptive_hls_s_luma[7]
		fprintf(setting,"\n");
		WriteReg8(0x200003a0, 0x98);//hdr_ae_adaptive_hw_gma_ratio[0]
		WriteReg8(0x200003a1, 0x9c);//hdr_ae_adaptive_hw_gma_ratio[1]
		WriteReg8(0x200003a2, 0xA0);//hdr_ae_adaptive_hw_gma_ratio[2]
		WriteReg8(0x200003a3, 0xa4);//hdr_ae_adaptive_hw_gma_ratio[3]
		WriteReg8(0x200003a4, 0xa8);//hdr_ae_adaptive_hw_gma_ratio[4]
		WriteReg8(0x200003a5, 0xac);//hdr_ae_adaptive_hw_gma_ratio[5]
		WriteReg8(0x200003a6, 0xb0);//hdr_ae_adaptive_hw_gma_ratio[6]
		WriteReg8(0x200003a7, 0xb4);//hdr_ae_adaptive_hw_gma_ratio[7]
		fprintf(setting,"\n");
		WriteReg8(0x200003a8, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[0]
		WriteReg8(0x200003a9, 0x08);//hdr_ae_adaptive_hw_tm_hist_th[0]
		WriteReg8(0x200003aa, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[1]
		WriteReg8(0x200003ab, 0x07);//hdr_ae_adaptive_hw_tm_hist_th[1]
		WriteReg8(0x200003ac, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[2]
		WriteReg8(0x200003ad, 0x04);//hdr_ae_adaptive_hw_tm_hist_th[2]
		WriteReg8(0x200003ae, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[3]
		WriteReg8(0x200003af, 0x04);//hdr_ae_adaptive_hw_tm_hist_th[3]
		WriteReg8(0x200003b0, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[4]
		WriteReg8(0x200003b1, 0x04);//hdr_ae_adaptive_hw_tm_hist_th[4]
		WriteReg8(0x200003b2, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[5]
		WriteReg8(0x200003b3, 0x03);//hdr_ae_adaptive_hw_tm_hist_th[5]
		WriteReg8(0x200003b4, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[6]
		WriteReg8(0x200003b5, 0x03);//hdr_ae_adaptive_hw_tm_hist_th[6]
		WriteReg8(0x200003b6, 0x00);//hdr_ae_adaptive_hw_tm_hist_th[7]
		WriteReg8(0x200003b7, 0x03);//hdr_ae_adaptive_hw_tm_hist_th[7]
		WriteReg8(0x200003b8, 0x01);//hdr_ae_luma_cpnst_oer_en
		WriteReg8(0x200003b9, 0x01);//hdr_ae_luma_cpnst_uer_en
		fprintf(setting,"\n");
		WriteReg8(0x20000363, 0x00);//hdr_ae_adaptive_dr_apply_mapping
		WriteReg8(0x200003c0, 0x20);//hdr_ae_adaptive_dr_wave
		WriteReg8(0x200003c2, 0x50);//hdr_ae_adaptive_avg_apply_mapping
		WriteReg8(0x200003c3, 0x20);//hdr_ae_adaptive_avg_wave
		fprintf(setting,"\n");
		WriteReg8(0x2000030b, 0x20);//hdr_ae_hls_l_num
		WriteReg8(0x2000030c, 0x80);//hdr_ae_hls_l_luma_cter[7:0]
		WriteReg8(0x2000030d, 0x02);//hdr_ae_hls_l_luma_cter[15:8]
		WriteReg8(0x2000030e, 0x20);//hdr_ae_hls_l_luma_wave[7:0]
		WriteReg8(0x2000030f, 0x00);//hdr_ae_hls_l_luma_wave[15:8]
		WriteReg8(0x20000352, 0x08);//hdr_ae_hls_s_num
		WriteReg8(0x20000354, 0xc8);//hdr_ae_hls_s_luma_cter[7:0]
		WriteReg8(0x20000355, 0x00);//hdr_ae_hls_s_luma_cter[15:8]
		WriteReg8(0x20000356, 0x20);//hdr_ae_hls_s_luma_wave[7:0]
		WriteReg8(0x20000357, 0x00);//hdr_ae_hls_s_luma_wave[15:8]
  	fprintf(setting,"\n");
		WriteReg8(0x200003ce, 0x00);//hdr_ae_expo_ratio_ls_man_en
		WriteReg8(0x200003cf, 0x01);//hdr_ae_expo_ratio_sv_man_en
		WriteReg8(0x200003d0, 0x10);//hdr_ae_expo_ratio_ls_man
		WriteReg8(0x200003d1, 0x04);//hdr_ae_expo_ratio_sv_man
		WriteReg8(0x200003d2, 0x01);//hdr_ae_expo_ratio_fw_en
		WriteReg8(0x200003d3, 0x01);//hdr_ae_expo_ratio_iir_en
		WriteReg8(0x200003d4, 0x80);//hdr_ae_expo_ratio_iir_speed
		WriteReg8(0x200003d5, 0x08);//hdr_ae_expo_ratio_iir_step
		WriteReg8(0x200003d6, 0x60);//hdr_ae_expo_ratio_ls_scale
		WriteReg8(0x200003d7, 0x60);//hdr_ae_expo_ratio_sv_scale

		fprintf(setting,"\n");
		WriteReg8(0x200003dc,0x00);//cmbwe_hds_en
		WriteReg8(0x200003d8,0x20);//hdr_ae_hds_oer_thl[ 7: 0]
		WriteReg8(0x200003d9,0x00);
		WriteReg8(0x200003da,0x40);//hdr_ae_hds_oer_thh[7:0]
		WriteReg8(0x200003db,0x00);
		WriteReg8(0x200003dd,0x10);//hdr_ae_hds_frame_num_th		
		
		fprintf(setting,"\n");
		WriteReg8(0x200003df,0x00);//cmbwe_gain_en
		WriteReg8(0x200003e0, 0x80);//hdr_ae_cmb_weight_gain_list[0]
		WriteReg8(0x200003e1, 0x78);//hdr_ae_cmb_weight_gain_list[1]
		WriteReg8(0x200003e2, 0x70);//hdr_ae_cmb_weight_gain_list[2]
		WriteReg8(0x200003e3, 0x68);//hdr_ae_cmb_weight_gain_list[3]
		WriteReg8(0x200003e4, 0x60);//hdr_ae_cmb_weight_gain_list[4]
		WriteReg8(0x200003e5, 0x58);//hdr_ae_cmb_weight_gain_list[5]
		WriteReg8(0x200003e6, 0x50);//hdr_ae_cmb_weight_gain_list[6]
		WriteReg8(0x200003e7, 0x48);//hdr_ae_cmb_weight_gain_list[7]
		WriteReg8(0x200003e8, 0x40);//hdr_ae_cmb_weight_gain_list[8]
		fprintf(setting,"\n");
		WriteReg8(0x200003e9, 0x00);//hdr_ae_cmb_weight_gain_man_en
		WriteReg8(0x200003ea, 0x00);//hdr_ae_cmb_weight_gain_man

		fprintf(setting,"\n");
		WriteReg8(0x200003eb,0x00);//cmbwe_man_en;
		WriteReg8(0x200003ec,0x00);//cmbwe_man_mode;
		WriteReg8(0x200003ed,0x00);//cmbwe_man_list[0];
		WriteReg8(0x200003ee,0x30);//cmbwe_man_list[1];
		WriteReg8(0x200003ef,0x60);//cmbwe_man_list[2];
		fprintf(setting,"\n");
		WriteReg8(0x200003f0, 0x01);//hdr_ae_cmb_weight_iir_en
		WriteReg8(0x200003f1, 0x80);//hdr_ae_cmb_weight_iir_speed
		WriteReg8(0x200003f2, 0x08);//hdr_ae_cmb_weight_iir_step	
		fprintf(setting,"\n");
		WriteReg8(0x200003f4, 0x00);//hdr_ae_speed_mode_auto_en
		WriteReg8(0x200003fd, 0x00);//hdr_ae_speed_mode_man
		WriteReg8(0x200003fe, 0x01);//hdr_ae_speed_factor_slow_b2d
		WriteReg8(0x200003ff, 0x01);//hdr_ae_speed_factor_slow_d2b
	}
	
}


///////////////////////////////////////////////////////////////////////////////
//Function : AF
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  AF_cfg (void)
{
	fprintf(setting,"\n");
	WriteReg8(0x200009d7, 0x06);//nMotorDriveMode
	WriteReg8(0x200009f1, 0x18);//nFocusDeviceID
	WriteReg8(0x200009f2, 0x00);//motor_set[15:8]
	WriteReg8(0x200009f3, 0x00);//motor_set[7:0]
	WriteReg8(0x20000a06, 0x04);//s_nDACLeftShift
	fprintf(setting,"\n");
	WriteReg8(0x20000863, 0x1d);//frame_rate   
	WriteReg8(0x200009e3, 0x00);  
	WriteReg8(0x200009e2, 0x80);//motor_used_time
	fprintf(setting,"\n");
	WriteReg8(0x200008e4, 0x01);//previous_move
	//WriteReg8(0x200008e5, 0xff);
	WriteReg8(0x20000888, 0x08);//over_peak_ratio
	WriteReg8(0x20000865, 0x01);
	WriteReg8(0x20000864, 0x00);//base_step
	WriteReg8(0x20000866, 0x0c);//coarse_min_step_ratio
	WriteReg8(0x20000867, 0x14);//coarse_step_ratio
	WriteReg8(0x20000868, 0x0a);//FINE_step
	WriteReg8(0x20000869, 0x08);//FINE_step
	fprintf(setting,"\n");
	WriteReg8(0x2000087b, 0x00);//compare-coarse
	WriteReg8(0x2000087a, 0x30);
	WriteReg8(0x2000087d, 0x00);//compare-coarse
	WriteReg8(0x2000087c, 0x50);
	WriteReg8(0x2000087f, 0x00);//compare-fine
	WriteReg8(0x2000087e, 0x18);
	WriteReg8(0x20000881, 0x00);//compare-fine
	WriteReg8(0x20000880, 0x30);
	fprintf(setting,"\n");
	WriteReg8(0x200009f9, 0x01);//DAC_MIN
	WriteReg8(0x200009f8, 0x00);
	WriteReg8(0x200009fb, 0x03);//DAC_MAX
	WriteReg8(0x200009fa, 0x00);
	fprintf(setting,"\n");
	WriteReg8(0x2000088a, 0x02);//failure_choose
	WriteReg8(0x20000ab4, 0x18);//AF_Stat_Ratio
	WriteReg8(0x20000b6d, 0x00);//HW_max_low_thrshold
	WriteReg8(0x20000b6c, 0x60);
	WriteReg8(0x20000b6a, 0x18);//HistDvalue_MAX
	fprintf(setting,"\n");
	WriteReg8(0x2000086b, 0x00);
	WriteReg8(0x2000086a, 0x14);
	WriteReg8(0x2000086d, 0x00);
	WriteReg8(0x2000086c, 0x08);
	fprintf(setting,"\n");
	WriteReg8(0x2000086f, 0x00);
	WriteReg8(0x2000086e, 0x10);
	WriteReg8(0x20000871, 0x00);
	WriteReg8(0x20000870, 0x12);
	fprintf(setting,"\n");
	WriteReg8(0x20000873, 0x00);
	WriteReg8(0x20000872, 0x06);
	WriteReg8(0x20000875, 0x00);
	WriteReg8(0x20000874, 0x08);
	fprintf(setting,"\n");
	WriteReg8(0x20000877, 0x00);
	WriteReg8(0x20000876, 0x00);
	WriteReg8(0x20000879, 0x00);
	WriteReg8(0x20000878, 0x00);
	fprintf(setting,"\n");
	WriteReg8(0x20000882, 0x08);
	WriteReg8(0x20000883, 0x00);//gain
	fprintf(setting,"\n");
	WriteReg8(0x20000884, 0x1c);
	fprintf(setting,"\n");
	WriteReg8(0x20000b24, 0x01);//detect
	WriteReg8(0x20000b25, 0x00);
	WriteReg8(0x2000088c, 0x18);//detect_last_mean_change 
	WriteReg8(0x2000088d, 0x14);//detect_last_mean_diff_value_change
	WriteReg8(0x2000088e, 0x18);//detect_histogram_difference
	fprintf(setting,"\n");
	WriteReg8(0x2000088b, 0x80);//contrast_change_ratio
	WriteReg8(0x20000890, 0xc0);
}


///////////////////////////////////////////////////////////////////////////////
//Function : BLC
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  BLC_cfg (unsigned char hdr_mode)
{
	fprintf(setting,"//blc_dgain\n");
	WriteReg8(ISP0_BASE_ADDR+0x00a0, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a1, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a2, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a3, 0x10);//blc_sub_dgain
	WriteReg8(ISP0_BASE_ADDR+0x00a4, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a5, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a6, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a7, 0x10);//blc_add_dgain
	fprintf(setting,"\n");
	fprintf(setting,"//blc_lenc\n");
	WriteReg8(ISP0_BASE_ADDR+0x00a8, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00a9, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00aa, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00ab, 0x10);//blc_sub_lenc
	WriteReg8(ISP0_BASE_ADDR+0x00ac, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00ad, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00ae, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00af, 0x10);//blc_add_lenc
	fprintf(setting,"\n");
	fprintf(setting,"//blc_awb\n");
	WriteReg8(ISP0_BASE_ADDR+0x00b0, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b1, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b2, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b3, 0x10);//blc_sub_awb
	WriteReg8(ISP0_BASE_ADDR+0x00b4, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b5, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b6, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x00b7, 0x10);//blc_add_awb
	
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x071b, 0x10);//awb_L_stat_blc	
	if (hdr_mode !=0) {
		WriteReg8(ISP0_BASE_ADDR+0x451b, 0x10);//awb_S_stat_blc		
	}
	if (hdr_mode ==3) {
		WriteReg8(ISP0_BASE_ADDR+0x471b, 0x10);//awb_VS_stat_blc
	}
	
	fprintf(setting,"\n");
	fprintf(setting,"//blc_add and blc_sub all enable\n");
	//0x80300015:bit[1]:yuv_gamma_loc:0:yuv_gamma ->ynr, 1:ynr ->yuv_gamma; bit[0]:raw_gamma_loc:0:raw_gamma ->snr, 1:snr ->raw_gamma
	WriteReg8(ISP0_BASE_ADDR+0x0015, 0xb1);//bit[5]:awb_gain_blc_add_en; bit[4]:awb_gain_blc_sub_en
	WriteReg8(ISP0_BASE_ADDR+0x0051, 0x03);//bit[3]:dgain_blc_en; bit[2:0]:avg_in_sel
	WriteReg8(ISP0_BASE_ADDR+0x3704, 0x07);//bit[2]:dgain_blc_sub_en; bit[1]:dgain_blc_add_en
	WriteReg8(ISP0_BASE_ADDR+0x3744, 0x07);//bit[2]:dgain_blc_sub_en; bit[1]:dgain_blc_add_en
	WriteReg8(ISP0_BASE_ADDR+0x3784, 0x07);//bit[2]:dgain_blc_sub_en; bit[1]:dgain_blc_add_en
	WriteReg8(ISP0_BASE_ADDR+0x03c4, 0x07);//bit[2]:lenc_blc_sub_en; bit[1]:lenc_blc_add_en
	WriteReg8(ISP0_BASE_ADDR+0x02c4, 0x07);//bit[2]:lenc_blc_sub_en; bit[1]:lenc_blc_add_en
	WriteReg8(ISP0_BASE_ADDR+0x04c4, 0x07);//bit[2]:lenc_blc_sub_en; bit[1]:lenc_blc_add_en
}


///////////////////////////////////////////////////////////////////////////////
//Function : LENC
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  Lenc_cfg (unsigned char hdr_mode)
{
/*
	//hardware register for test
	fprintf(setting,"//hardware_lenc_long\n");
	WriteReg8(ISP0_BASE_ADDR+0x0300, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0301, 0x0f);
	WriteReg8(ISP0_BASE_ADDR+0x0302, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x0303, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x0304, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x0305, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x0306, 0x0e);
	WriteReg8(ISP0_BASE_ADDR+0x0307, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x0308, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x0309, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x030a, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x030b, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x030c, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x030d, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x030e, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x030f, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x0310, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0311, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x0312, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0313, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0314, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0315, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0316, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x0317, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x0318, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x0319, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x031a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x031b, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x031c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x031d, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x031e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x031f, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0320, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x0321, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0322, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0323, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0324, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0325, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0326, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0327, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0328, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0329, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x032a, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x032b, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x032c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x032d, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x032e, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x032f, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x0330, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x0331, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x0332, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0333, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x0334, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x0335, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0336, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x0337, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x0338, 0x19);
	WriteReg8(ISP0_BASE_ADDR+0x0339, 0x0f);
	WriteReg8(ISP0_BASE_ADDR+0x033a, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x033b, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x033c, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x033d, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x033e, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x033f, 0x15);
	WriteReg8(ISP0_BASE_ADDR+0x0340, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x0341, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0342, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0343, 0x1e);
	WriteReg8(ISP0_BASE_ADDR+0x0344, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0345, 0x1e);
	WriteReg8(ISP0_BASE_ADDR+0x0346, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0347, 0x1b);
	WriteReg8(ISP0_BASE_ADDR+0x0348, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x0349, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x034a, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x034b, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x034c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x034d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x034e, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x034f, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0350, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0351, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0352, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0353, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0354, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0355, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0356, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0357, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0358, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0359, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035a, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035b, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035e, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x035f, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0360, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0361, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0362, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0363, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0364, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0365, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0366, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0367, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0368, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0369, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036a, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036b, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036e, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x036f, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0370, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x0371, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0372, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0373, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0374, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0375, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0376, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0377, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x0378, 0x1a);
	WriteReg8(ISP0_BASE_ADDR+0x0379, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037a, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037b, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037c, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037d, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037e, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x037f, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x0380, 0x2b);
	WriteReg8(ISP0_BASE_ADDR+0x0381, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x0382, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x0383, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x0384, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x0385, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x0386, 0x29);
	WriteReg8(ISP0_BASE_ADDR+0x0387, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x0388, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x0389, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x038a, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x038b, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x038c, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x038d, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x038e, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x038f, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x0390, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x0391, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0392, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0393, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0394, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0395, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0396, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x0397, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x0398, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x0399, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x039a, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x039b, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x039c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x039d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x039e, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x039f, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x03a0, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x03a1, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x03a2, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x03a3, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x03a4, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x03a5, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x03a6, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x03a7, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x03a8, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x03a9, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x03aa, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x03ab, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x03ac, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x03ad, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x03ae, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x03af, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x03b0, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x03b1, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x03b2, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x03b3, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x03b4, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x03b5, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x03b6, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x03b7, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x03b8, 0x29);
	WriteReg8(ISP0_BASE_ADDR+0x03b9, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x03ba, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x03bb, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x03bc, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x03bd, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x03be, 0x29);
	WriteReg8(ISP0_BASE_ADDR+0x03bf, 0x29);

	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		fprintf(setting,"//hardware_lenc_short\n");
		WriteReg8(ISP0_BASE_ADDR+0x0200, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0201, 0x0f);
		WriteReg8(ISP0_BASE_ADDR+0x0202, 0x0c);
		WriteReg8(ISP0_BASE_ADDR+0x0203, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x0204, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x0205, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x0206, 0x0e);
		WriteReg8(ISP0_BASE_ADDR+0x0207, 0x18);
		WriteReg8(ISP0_BASE_ADDR+0x0208, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0209, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x020a, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x020b, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x020c, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x020d, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x020e, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x020f, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0210, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0211, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0212, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0213, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0214, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0215, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0216, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0217, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0218, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0219, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x021a, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x021b, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x021c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x021d, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x021e, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x021f, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0220, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0221, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0222, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0223, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0224, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0225, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0226, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0227, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0228, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0229, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x022a, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x022b, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x022c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x022d, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x022e, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x022f, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0230, 0x07);
		WriteReg8(ISP0_BASE_ADDR+0x0231, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x0232, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0233, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0234, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0235, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0236, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x0237, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0238, 0x19);
		WriteReg8(ISP0_BASE_ADDR+0x0239, 0x0f);
		WriteReg8(ISP0_BASE_ADDR+0x023a, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x023b, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x023c, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x023d, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x023e, 0x0d);
		WriteReg8(ISP0_BASE_ADDR+0x023f, 0x15);
		WriteReg8(ISP0_BASE_ADDR+0x0240, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0241, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0242, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0243, 0x1e);
		WriteReg8(ISP0_BASE_ADDR+0x0244, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0245, 0x1e);
		WriteReg8(ISP0_BASE_ADDR+0x0246, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0247, 0x1b);
		WriteReg8(ISP0_BASE_ADDR+0x0248, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0249, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x024a, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x024b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x024c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x024d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x024e, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x024f, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0250, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0251, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0252, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0253, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0254, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0255, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0256, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0257, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0258, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0259, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025a, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025e, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x025f, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0260, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0261, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0262, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0263, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0264, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0265, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0266, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0267, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0268, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0269, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026a, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026e, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x026f, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0270, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0271, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0272, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0273, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0274, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0275, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0276, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0277, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0278, 0x1a);
		WriteReg8(ISP0_BASE_ADDR+0x0279, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027a, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027b, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027c, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027d, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027e, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x027f, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0280, 0x2b);
		WriteReg8(ISP0_BASE_ADDR+0x0281, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0282, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0283, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x0284, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x0285, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0286, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x0287, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0288, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0289, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x028a, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x028b, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x028c, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x028d, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x028e, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x028f, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0290, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x0291, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0292, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0293, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0294, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0295, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0296, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x0297, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x0298, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x0299, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x029a, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x029b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x029c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x029d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x029e, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x029f, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x02a0, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x02a1, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x02a2, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x02a3, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x02a4, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x02a5, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x02a6, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x02a7, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x02a8, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x02a9, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x02aa, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x02ab, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x02ac, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x02ad, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x02ae, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x02af, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x02b0, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x02b1, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x02b2, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x02b3, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x02b4, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x02b5, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x02b6, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x02b7, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x02b8, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x02b9, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x02ba, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x02bb, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x02bc, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x02bd, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x02be, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x02bf, 0x29);
	}

	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		fprintf(setting,"//hardware_lenc_vs\n");
		WriteReg8(ISP0_BASE_ADDR+0x0400, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0401, 0x0f);
		WriteReg8(ISP0_BASE_ADDR+0x0402, 0x0c);
		WriteReg8(ISP0_BASE_ADDR+0x0403, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x0404, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x0405, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x0406, 0x0e);
		WriteReg8(ISP0_BASE_ADDR+0x0407, 0x18);
		WriteReg8(ISP0_BASE_ADDR+0x0408, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0409, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x040a, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x040b, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x040c, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x040d, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x040e, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x040f, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0410, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0411, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0412, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0413, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0414, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0415, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0416, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0417, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0418, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0419, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x041a, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x041b, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x041c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x041d, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x041e, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x041f, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0420, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x0421, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0422, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0423, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0424, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0425, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0426, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x0427, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x0428, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0429, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x042a, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x042b, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x042c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x042d, 0x01);
		WriteReg8(ISP0_BASE_ADDR+0x042e, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x042f, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0430, 0x07);
		WriteReg8(ISP0_BASE_ADDR+0x0431, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x0432, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0433, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0434, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x0435, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x0436, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x0437, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x0438, 0x19);
		WriteReg8(ISP0_BASE_ADDR+0x0439, 0x0f);
		WriteReg8(ISP0_BASE_ADDR+0x043a, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x043b, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x043c, 0x0a);
		WriteReg8(ISP0_BASE_ADDR+0x043d, 0x0b);
		WriteReg8(ISP0_BASE_ADDR+0x043e, 0x0d);
		WriteReg8(ISP0_BASE_ADDR+0x043f, 0x15);
		WriteReg8(ISP0_BASE_ADDR+0x0440, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0441, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0442, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0443, 0x1e);
		WriteReg8(ISP0_BASE_ADDR+0x0444, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0445, 0x1e);
		WriteReg8(ISP0_BASE_ADDR+0x0446, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0447, 0x1b);
		WriteReg8(ISP0_BASE_ADDR+0x0448, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0449, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x044a, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x044b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x044c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x044d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x044e, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x044f, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0450, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0451, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0452, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0453, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0454, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0455, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0456, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0457, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0458, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0459, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045a, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045e, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x045f, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0460, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0461, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0462, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0463, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0464, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0465, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0466, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0467, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0468, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0469, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046a, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046e, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x046f, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0470, 0x1c);
		WriteReg8(ISP0_BASE_ADDR+0x0471, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0472, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0473, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0474, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0475, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x0476, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0477, 0x1f);
		WriteReg8(ISP0_BASE_ADDR+0x0478, 0x1a);
		WriteReg8(ISP0_BASE_ADDR+0x0479, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047a, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047b, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047c, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047d, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047e, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x047f, 0x1d);
		WriteReg8(ISP0_BASE_ADDR+0x0480, 0x2b);
		WriteReg8(ISP0_BASE_ADDR+0x0481, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0482, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0483, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x0484, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x0485, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0486, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x0487, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x0488, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0489, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x048a, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x048b, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x048c, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x048d, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x048e, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x048f, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x0490, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x0491, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0492, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0493, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0494, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0495, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x0496, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x0497, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x0498, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x0499, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x049a, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x049b, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x049c, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x049d, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x049e, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x049f, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x04a0, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x04a1, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x04a2, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x04a3, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x04a4, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x04a5, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x04a6, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x04a7, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x04a8, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x04a9, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x04aa, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x04ab, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x04ac, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x04ad, 0x22);
		WriteReg8(ISP0_BASE_ADDR+0x04ae, 0x23);
		WriteReg8(ISP0_BASE_ADDR+0x04af, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x04b0, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x04b1, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x04b2, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x04b3, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x04b4, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x04b5, 0x24);
		WriteReg8(ISP0_BASE_ADDR+0x04b6, 0x25);
		WriteReg8(ISP0_BASE_ADDR+0x04b7, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x04b8, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x04b9, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x04ba, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x04bb, 0x26);
		WriteReg8(ISP0_BASE_ADDR+0x04bc, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x04bd, 0x27);
		WriteReg8(ISP0_BASE_ADDR+0x04be, 0x29);
		WriteReg8(ISP0_BASE_ADDR+0x04bf, 0x29);
	}
*/
	//autolenc for actual use
	fprintf(setting,"//auto_lenc_ct\n");
	WriteReg8(0x20000846, 0x70);
	WriteReg8(0x20000847, 0x00);//Alight_CT_thr
	WriteReg8(0x20000848, 0xc0);
	WriteReg8(0x20000849, 0x00);//Clight_CT_thr
	WriteReg8(0x2000084a, 0x0d);
	WriteReg8(0x2000084b, 0x01);//Dlight_CT_thr
	fprintf(setting,"\n");
	fprintf(setting,"//auto_lenc_Alight\n");
	WriteReg8(0x20000604, 0x3f);
	WriteReg8(0x20000605, 0x30);
	WriteReg8(0x20000606, 0x21);
	WriteReg8(0x20000607, 0x1d);
	WriteReg8(0x20000608, 0x1d);
	WriteReg8(0x20000609, 0x24);
	WriteReg8(0x2000060a, 0x37);
	WriteReg8(0x2000060b, 0x3f);
	WriteReg8(0x2000060c, 0x20);
	WriteReg8(0x2000060d, 0x16);
	WriteReg8(0x2000060e, 0x12);
	WriteReg8(0x2000060f, 0x10);
	WriteReg8(0x20000610, 0x10);
	WriteReg8(0x20000611, 0x13);
	WriteReg8(0x20000612, 0x19);
	WriteReg8(0x20000613, 0x29);
	WriteReg8(0x20000614, 0x13);
	WriteReg8(0x20000615, 0x0e);
	WriteReg8(0x20000616, 0x08);
	WriteReg8(0x20000617, 0x05);
	WriteReg8(0x20000618, 0x06);
	WriteReg8(0x20000619, 0x0a);
	WriteReg8(0x2000061a, 0x10);
	WriteReg8(0x2000061b, 0x16);
	WriteReg8(0x2000061c, 0x10);
	WriteReg8(0x2000061d, 0x08);
	WriteReg8(0x2000061e, 0x02);
	WriteReg8(0x2000061f, 0x00);
	WriteReg8(0x20000620, 0x00);
	WriteReg8(0x20000621, 0x03);
	WriteReg8(0x20000622, 0x0b);
	WriteReg8(0x20000623, 0x13);
	WriteReg8(0x20000624, 0x11);
	WriteReg8(0x20000625, 0x08);
	WriteReg8(0x20000626, 0x02);
	WriteReg8(0x20000627, 0x00);
	WriteReg8(0x20000628, 0x00);
	WriteReg8(0x20000629, 0x04);
	WriteReg8(0x2000062a, 0x0b);
	WriteReg8(0x2000062b, 0x13);
	WriteReg8(0x2000062c, 0x14);
	WriteReg8(0x2000062d, 0x0f);
	WriteReg8(0x2000062e, 0x09);
	WriteReg8(0x2000062f, 0x06);
	WriteReg8(0x20000630, 0x06);
	WriteReg8(0x20000631, 0x0b);
	WriteReg8(0x20000632, 0x10);
	WriteReg8(0x20000633, 0x16);
	WriteReg8(0x20000634, 0x25);
	WriteReg8(0x20000635, 0x18);
	WriteReg8(0x20000636, 0x13);
	WriteReg8(0x20000637, 0x11);
	WriteReg8(0x20000638, 0x11);
	WriteReg8(0x20000639, 0x13);
	WriteReg8(0x2000063a, 0x1a);
	WriteReg8(0x2000063b, 0x2c);
	WriteReg8(0x2000063c, 0x3f);
	WriteReg8(0x2000063d, 0x3a);
	WriteReg8(0x2000063e, 0x28);
	WriteReg8(0x2000063f, 0x22);
	WriteReg8(0x20000640, 0x22);
	WriteReg8(0x20000641, 0x2a);
	WriteReg8(0x20000642, 0x3f);
	WriteReg8(0x20000643, 0x3f);
	WriteReg8(0x20000644, 0x1d);
	WriteReg8(0x20000645, 0x1f);
	WriteReg8(0x20000646, 0x1d);
	WriteReg8(0x20000647, 0x1e);
	WriteReg8(0x20000648, 0x1d);
	WriteReg8(0x20000649, 0x1e);
	WriteReg8(0x2000064a, 0x1e);
	WriteReg8(0x2000064b, 0x1e);
	WriteReg8(0x2000064c, 0x1e);
	WriteReg8(0x2000064d, 0x1f);
	WriteReg8(0x2000064e, 0x1f);
	WriteReg8(0x2000064f, 0x1f);
	WriteReg8(0x20000650, 0x1f);
	WriteReg8(0x20000651, 0x1e);
	WriteReg8(0x20000652, 0x1e);
	WriteReg8(0x20000653, 0x1d);
	WriteReg8(0x20000654, 0x1e);
	WriteReg8(0x20000655, 0x1f);
	WriteReg8(0x20000656, 0x1e);
	WriteReg8(0x20000657, 0x1f);
	WriteReg8(0x20000658, 0x1e);
	WriteReg8(0x20000659, 0x1d);
	WriteReg8(0x2000065a, 0x1d);
	WriteReg8(0x2000065b, 0x1e);
	WriteReg8(0x2000065c, 0x1f);
	WriteReg8(0x2000065d, 0x1f);
	WriteReg8(0x2000065e, 0x20);
	WriteReg8(0x2000065f, 0x21);
	WriteReg8(0x20000660, 0x1f);
	WriteReg8(0x20000661, 0x1e);
	WriteReg8(0x20000662, 0x1f);
	WriteReg8(0x20000663, 0x1e);
	WriteReg8(0x20000664, 0x1f);
	WriteReg8(0x20000665, 0x20);
	WriteReg8(0x20000666, 0x20);
	WriteReg8(0x20000667, 0x21);
	WriteReg8(0x20000668, 0x20);
	WriteReg8(0x20000669, 0x1f);
	WriteReg8(0x2000066a, 0x1f);
	WriteReg8(0x2000066b, 0x1e);
	WriteReg8(0x2000066c, 0x1e);
	WriteReg8(0x2000066d, 0x1f);
	WriteReg8(0x2000066e, 0x1f);
	WriteReg8(0x2000066f, 0x20);
	WriteReg8(0x20000670, 0x1f);
	WriteReg8(0x20000671, 0x1e);
	WriteReg8(0x20000672, 0x1e);
	WriteReg8(0x20000673, 0x1d);
	WriteReg8(0x20000674, 0x1e);
	WriteReg8(0x20000675, 0x20);
	WriteReg8(0x20000676, 0x20);
	WriteReg8(0x20000677, 0x21);
	WriteReg8(0x20000678, 0x20);
	WriteReg8(0x20000679, 0x1e);
	WriteReg8(0x2000067a, 0x1e);
	WriteReg8(0x2000067b, 0x1d);
	WriteReg8(0x2000067c, 0x1f);
	WriteReg8(0x2000067d, 0x1f);
	WriteReg8(0x2000067e, 0x1f);
	WriteReg8(0x2000067f, 0x1f);
	WriteReg8(0x20000680, 0x1e);
	WriteReg8(0x20000681, 0x1e);
	WriteReg8(0x20000682, 0x1d);
	WriteReg8(0x20000683, 0x1f);
	WriteReg8(0x20000684, 0x2d);
	WriteReg8(0x20000685, 0x29);
	WriteReg8(0x20000686, 0x29);
	WriteReg8(0x20000687, 0x2a);
	WriteReg8(0x20000688, 0x2a);
	WriteReg8(0x20000689, 0x2a);
	WriteReg8(0x2000068a, 0x2b);
	WriteReg8(0x2000068b, 0x32);
	WriteReg8(0x2000068c, 0x2b);
	WriteReg8(0x2000068d, 0x2c);
	WriteReg8(0x2000068e, 0x2b);
	WriteReg8(0x2000068f, 0x2a);
	WriteReg8(0x20000690, 0x2b);
	WriteReg8(0x20000691, 0x2c);
	WriteReg8(0x20000692, 0x2d);
	WriteReg8(0x20000693, 0x2b);
	WriteReg8(0x20000694, 0x2b);
	WriteReg8(0x20000695, 0x2a);
	WriteReg8(0x20000696, 0x25);
	WriteReg8(0x20000697, 0x24);
	WriteReg8(0x20000698, 0x24);
	WriteReg8(0x20000699, 0x27);
	WriteReg8(0x2000069a, 0x2c);
	WriteReg8(0x2000069b, 0x2c);
	WriteReg8(0x2000069c, 0x28);
	WriteReg8(0x2000069d, 0x26);
	WriteReg8(0x2000069e, 0x21);
	WriteReg8(0x2000069f, 0x1f);
	WriteReg8(0x200006a0, 0x20);
	WriteReg8(0x200006a1, 0x23);
	WriteReg8(0x200006a2, 0x29);
	WriteReg8(0x200006a3, 0x2b);
	WriteReg8(0x200006a4, 0x28);
	WriteReg8(0x200006a5, 0x26);
	WriteReg8(0x200006a6, 0x21);
	WriteReg8(0x200006a7, 0x20);
	WriteReg8(0x200006a8, 0x20);
	WriteReg8(0x200006a9, 0x24);
	WriteReg8(0x200006aa, 0x29);
	WriteReg8(0x200006ab, 0x2b);
	WriteReg8(0x200006ac, 0x2b);
	WriteReg8(0x200006ad, 0x2b);
	WriteReg8(0x200006ae, 0x26);
	WriteReg8(0x200006af, 0x26);
	WriteReg8(0x200006b0, 0x26);
	WriteReg8(0x200006b1, 0x29);
	WriteReg8(0x200006b2, 0x2d);
	WriteReg8(0x200006b3, 0x2b);
	WriteReg8(0x200006b4, 0x2c);
	WriteReg8(0x200006b5, 0x2d);
	WriteReg8(0x200006b6, 0x2c);
	WriteReg8(0x200006b7, 0x2c);
	WriteReg8(0x200006b8, 0x2c);
	WriteReg8(0x200006b9, 0x2e);
	WriteReg8(0x200006ba, 0x2e);
	WriteReg8(0x200006bb, 0x2e);
	WriteReg8(0x200006bc, 0x2e);
	WriteReg8(0x200006bd, 0x29);
	WriteReg8(0x200006be, 0x29);
	WriteReg8(0x200006bf, 0x2a);
	WriteReg8(0x200006c0, 0x2b);
	WriteReg8(0x200006c1, 0x2a);
	WriteReg8(0x200006c2, 0x2b);
	WriteReg8(0x200006c3, 0x30);
	fprintf(setting,"\n");
	fprintf(setting,"//auto_lenc_Clight\n");
	WriteReg8(0x200006c4, 0x3f);
	WriteReg8(0x200006c5, 0x2d);
	WriteReg8(0x200006c6, 0x1f);
	WriteReg8(0x200006c7, 0x1b);
	WriteReg8(0x200006c8, 0x1b);
	WriteReg8(0x200006c9, 0x23);
	WriteReg8(0x200006ca, 0x33);
	WriteReg8(0x200006cb, 0x3f);
	WriteReg8(0x200006cc, 0x20);
	WriteReg8(0x200006cd, 0x14);
	WriteReg8(0x200006ce, 0x10);
	WriteReg8(0x200006cf, 0x0e);
	WriteReg8(0x200006d0, 0x0f);
	WriteReg8(0x200006d1, 0x11);
	WriteReg8(0x200006d2, 0x16);
	WriteReg8(0x200006d3, 0x27);
	WriteReg8(0x200006d4, 0x13);
	WriteReg8(0x200006d5, 0x0d);
	WriteReg8(0x200006d6, 0x07);
	WriteReg8(0x200006d7, 0x04);
	WriteReg8(0x200006d8, 0x05);
	WriteReg8(0x200006d9, 0x09);
	WriteReg8(0x200006da, 0x0e);
	WriteReg8(0x200006db, 0x15);
	WriteReg8(0x200006dc, 0x10);
	WriteReg8(0x200006dd, 0x07);
	WriteReg8(0x200006de, 0x02);
	WriteReg8(0x200006df, 0x00);
	WriteReg8(0x200006e0, 0x00);
	WriteReg8(0x200006e1, 0x03);
	WriteReg8(0x200006e2, 0x0a);
	WriteReg8(0x200006e3, 0x12);
	WriteReg8(0x200006e4, 0x10);
	WriteReg8(0x200006e5, 0x07);
	WriteReg8(0x200006e6, 0x02);
	WriteReg8(0x200006e7, 0x00);
	WriteReg8(0x200006e8, 0x00);
	WriteReg8(0x200006e9, 0x03);
	WriteReg8(0x200006ea, 0x0a);
	WriteReg8(0x200006eb, 0x12);
	WriteReg8(0x200006ec, 0x13);
	WriteReg8(0x200006ed, 0x0d);
	WriteReg8(0x200006ee, 0x08);
	WriteReg8(0x200006ef, 0x05);
	WriteReg8(0x200006f0, 0x06);
	WriteReg8(0x200006f1, 0x0a);
	WriteReg8(0x200006f2, 0x0f);
	WriteReg8(0x200006f3, 0x15);
	WriteReg8(0x200006f4, 0x24);
	WriteReg8(0x200006f5, 0x16);
	WriteReg8(0x200006f6, 0x12);
	WriteReg8(0x200006f7, 0x0f);
	WriteReg8(0x200006f8, 0x10);
	WriteReg8(0x200006f9, 0x12);
	WriteReg8(0x200006fa, 0x18);
	WriteReg8(0x200006fb, 0x2b);
	WriteReg8(0x200006fc, 0x3f);
	WriteReg8(0x200006fd, 0x36);
	WriteReg8(0x200006fe, 0x25);
	WriteReg8(0x200006ff, 0x20);
	WriteReg8(0x20000700, 0x20);
	WriteReg8(0x20000701, 0x28);
	WriteReg8(0x20000702, 0x3b);
	WriteReg8(0x20000703, 0x3f);
	WriteReg8(0x20000704, 0x1a);
	WriteReg8(0x20000705, 0x1b);
	WriteReg8(0x20000706, 0x1a);
	WriteReg8(0x20000707, 0x1a);
	WriteReg8(0x20000708, 0x1a);
	WriteReg8(0x20000709, 0x19);
	WriteReg8(0x2000070a, 0x1b);
	WriteReg8(0x2000070b, 0x18);
	WriteReg8(0x2000070c, 0x19);
	WriteReg8(0x2000070d, 0x1b);
	WriteReg8(0x2000070e, 0x1a);
	WriteReg8(0x2000070f, 0x1b);
	WriteReg8(0x20000710, 0x1a);
	WriteReg8(0x20000711, 0x1a);
	WriteReg8(0x20000712, 0x19);
	WriteReg8(0x20000713, 0x1a);
	WriteReg8(0x20000714, 0x1a);
	WriteReg8(0x20000715, 0x1b);
	WriteReg8(0x20000716, 0x1c);
	WriteReg8(0x20000717, 0x1d);
	WriteReg8(0x20000718, 0x1c);
	WriteReg8(0x20000719, 0x1a);
	WriteReg8(0x2000071a, 0x1a);
	WriteReg8(0x2000071b, 0x19);
	WriteReg8(0x2000071c, 0x1a);
	WriteReg8(0x2000071d, 0x1c);
	WriteReg8(0x2000071e, 0x1e);
	WriteReg8(0x2000071f, 0x21);
	WriteReg8(0x20000720, 0x1f);
	WriteReg8(0x20000721, 0x1d);
	WriteReg8(0x20000722, 0x1b);
	WriteReg8(0x20000723, 0x1a);
	WriteReg8(0x20000724, 0x1a);
	WriteReg8(0x20000725, 0x1c);
	WriteReg8(0x20000726, 0x1f);
	WriteReg8(0x20000727, 0x21);
	WriteReg8(0x20000728, 0x20);
	WriteReg8(0x20000729, 0x1e);
	WriteReg8(0x2000072a, 0x1c);
	WriteReg8(0x2000072b, 0x1a);
	WriteReg8(0x2000072c, 0x1a);
	WriteReg8(0x2000072d, 0x1b);
	WriteReg8(0x2000072e, 0x1c);
	WriteReg8(0x2000072f, 0x1d);
	WriteReg8(0x20000730, 0x1d);
	WriteReg8(0x20000731, 0x1b);
	WriteReg8(0x20000732, 0x1a);
	WriteReg8(0x20000733, 0x19);
	WriteReg8(0x20000734, 0x1a);
	WriteReg8(0x20000735, 0x1b);
	WriteReg8(0x20000736, 0x1b);
	WriteReg8(0x20000737, 0x1c);
	WriteReg8(0x20000738, 0x1b);
	WriteReg8(0x20000739, 0x1a);
	WriteReg8(0x2000073a, 0x1a);
	WriteReg8(0x2000073b, 0x1a);
	WriteReg8(0x2000073c, 0x1c);
	WriteReg8(0x2000073d, 0x1a);
	WriteReg8(0x2000073e, 0x1a);
	WriteReg8(0x2000073f, 0x1a);
	WriteReg8(0x20000740, 0x1a);
	WriteReg8(0x20000741, 0x1a);
	WriteReg8(0x20000742, 0x1a);
	WriteReg8(0x20000743, 0x19);
	WriteReg8(0x20000744, 0x21);
	WriteReg8(0x20000745, 0x20);
	WriteReg8(0x20000746, 0x1f);
	WriteReg8(0x20000747, 0x1f);
	WriteReg8(0x20000748, 0x1f);
	WriteReg8(0x20000749, 0x1f);
	WriteReg8(0x2000074a, 0x21);
	WriteReg8(0x2000074b, 0x20);
	WriteReg8(0x2000074c, 0x21);
	WriteReg8(0x2000074d, 0x21);
	WriteReg8(0x2000074e, 0x1f);
	WriteReg8(0x2000074f, 0x1f);
	WriteReg8(0x20000750, 0x1f);
	WriteReg8(0x20000751, 0x20);
	WriteReg8(0x20000752, 0x21);
	WriteReg8(0x20000753, 0x21);
	WriteReg8(0x20000754, 0x1f);
	WriteReg8(0x20000755, 0x20);
	WriteReg8(0x20000756, 0x20);
	WriteReg8(0x20000757, 0x20);
	WriteReg8(0x20000758, 0x20);
	WriteReg8(0x20000759, 0x20);
	WriteReg8(0x2000075a, 0x21);
	WriteReg8(0x2000075b, 0x1f);
	WriteReg8(0x2000075c, 0x1d);
	WriteReg8(0x2000075d, 0x20);
	WriteReg8(0x2000075e, 0x20);
	WriteReg8(0x2000075f, 0x20);
	WriteReg8(0x20000760, 0x20);
	WriteReg8(0x20000761, 0x20);
	WriteReg8(0x20000762, 0x20);
	WriteReg8(0x20000763, 0x1f);
	WriteReg8(0x20000764, 0x1d);
	WriteReg8(0x20000765, 0x20);
	WriteReg8(0x20000766, 0x20);
	WriteReg8(0x20000767, 0x20);
	WriteReg8(0x20000768, 0x20);
	WriteReg8(0x20000769, 0x20);
	WriteReg8(0x2000076a, 0x20);
	WriteReg8(0x2000076b, 0x1f);
	WriteReg8(0x2000076c, 0x1f);
	WriteReg8(0x2000076d, 0x20);
	WriteReg8(0x2000076e, 0x20);
	WriteReg8(0x2000076f, 0x21);
	WriteReg8(0x20000770, 0x21);
	WriteReg8(0x20000771, 0x21);
	WriteReg8(0x20000772, 0x21);
	WriteReg8(0x20000773, 0x20);
	WriteReg8(0x20000774, 0x21);
	WriteReg8(0x20000775, 0x21);
	WriteReg8(0x20000776, 0x20);
	WriteReg8(0x20000777, 0x20);
	WriteReg8(0x20000778, 0x20);
	WriteReg8(0x20000779, 0x21);
	WriteReg8(0x2000077a, 0x22);
	WriteReg8(0x2000077b, 0x22);
	WriteReg8(0x2000077c, 0x21);
	WriteReg8(0x2000077d, 0x20);
	WriteReg8(0x2000077e, 0x20);
	WriteReg8(0x2000077f, 0x20);
	WriteReg8(0x20000780, 0x21);
	WriteReg8(0x20000781, 0x20);
	WriteReg8(0x20000782, 0x21);
	WriteReg8(0x20000783, 0x22);
	fprintf(setting,"\n");
	fprintf(setting,"//auto_lenc_Dlight\n");
	WriteReg8(0x20000784, 0x3f);
	WriteReg8(0x20000785, 0x2d);
	WriteReg8(0x20000786, 0x1f);
	WriteReg8(0x20000787, 0x1b);
	WriteReg8(0x20000788, 0x1b);
	WriteReg8(0x20000789, 0x22);
	WriteReg8(0x2000078a, 0x34);
	WriteReg8(0x2000078b, 0x3f);
	WriteReg8(0x2000078c, 0x20);
	WriteReg8(0x2000078d, 0x14);
	WriteReg8(0x2000078e, 0x10);
	WriteReg8(0x2000078f, 0x0e);
	WriteReg8(0x20000790, 0x0f);
	WriteReg8(0x20000791, 0x11);
	WriteReg8(0x20000792, 0x16);
	WriteReg8(0x20000793, 0x27);
	WriteReg8(0x20000794, 0x13);
	WriteReg8(0x20000795, 0x0c);
	WriteReg8(0x20000796, 0x07);
	WriteReg8(0x20000797, 0x04);
	WriteReg8(0x20000798, 0x05);
	WriteReg8(0x20000799, 0x09);
	WriteReg8(0x2000079a, 0x0f);
	WriteReg8(0x2000079b, 0x15);
	WriteReg8(0x2000079c, 0x10);
	WriteReg8(0x2000079d, 0x07);
	WriteReg8(0x2000079e, 0x02);
	WriteReg8(0x2000079f, 0x00);
	WriteReg8(0x200007a0, 0x00);
	WriteReg8(0x200007a1, 0x03);
	WriteReg8(0x200007a2, 0x0a);
	WriteReg8(0x200007a3, 0x12);
	WriteReg8(0x200007a4, 0x10);
	WriteReg8(0x200007a5, 0x07);
	WriteReg8(0x200007a6, 0x02);
	WriteReg8(0x200007a7, 0x00);
	WriteReg8(0x200007a8, 0x00);
	WriteReg8(0x200007a9, 0x03);
	WriteReg8(0x200007aa, 0x0a);
	WriteReg8(0x200007ab, 0x12);
	WriteReg8(0x200007ac, 0x13);
	WriteReg8(0x200007ad, 0x0d);
	WriteReg8(0x200007ae, 0x08);
	WriteReg8(0x200007af, 0x05);
	WriteReg8(0x200007b0, 0x06);
	WriteReg8(0x200007b1, 0x0a);
	WriteReg8(0x200007b2, 0x0f);
	WriteReg8(0x200007b3, 0x15);
	WriteReg8(0x200007b4, 0x24);
	WriteReg8(0x200007b5, 0x16);
	WriteReg8(0x200007b6, 0x11);
	WriteReg8(0x200007b7, 0x0f);
	WriteReg8(0x200007b8, 0x10);
	WriteReg8(0x200007b9, 0x12);
	WriteReg8(0x200007ba, 0x18);
	WriteReg8(0x200007bb, 0x2b);
	WriteReg8(0x200007bc, 0x3f);
	WriteReg8(0x200007bd, 0x36);
	WriteReg8(0x200007be, 0x25);
	WriteReg8(0x200007bf, 0x20);
	WriteReg8(0x200007c0, 0x20);
	WriteReg8(0x200007c1, 0x28);
	WriteReg8(0x200007c2, 0x3b);
	WriteReg8(0x200007c3, 0x3f);
	WriteReg8(0x200007c4, 0x1d);
	WriteReg8(0x200007c5, 0x1c);
	WriteReg8(0x200007c6, 0x1c);
	WriteReg8(0x200007c7, 0x1b);
	WriteReg8(0x200007c8, 0x1c);
	WriteReg8(0x200007c9, 0x1a);
	WriteReg8(0x200007ca, 0x1c);
	WriteReg8(0x200007cb, 0x1a);
	WriteReg8(0x200007cc, 0x1a);
	WriteReg8(0x200007cd, 0x1c);
	WriteReg8(0x200007ce, 0x1c);
	WriteReg8(0x200007cf, 0x1d);
	WriteReg8(0x200007d0, 0x1c);
	WriteReg8(0x200007d1, 0x1c);
	WriteReg8(0x200007d2, 0x1b);
	WriteReg8(0x200007d3, 0x1c);
	WriteReg8(0x200007d4, 0x1c);
	WriteReg8(0x200007d5, 0x1c);
	WriteReg8(0x200007d6, 0x1d);
	WriteReg8(0x200007d7, 0x1e);
	WriteReg8(0x200007d8, 0x1e);
	WriteReg8(0x200007d9, 0x1c);
	WriteReg8(0x200007da, 0x1c);
	WriteReg8(0x200007db, 0x1b);
	WriteReg8(0x200007dc, 0x1c);
	WriteReg8(0x200007dd, 0x1e);
	WriteReg8(0x200007de, 0x1f);
	WriteReg8(0x200007df, 0x21);
	WriteReg8(0x200007e0, 0x20);
	WriteReg8(0x200007e1, 0x1e);
	WriteReg8(0x200007e2, 0x1d);
	WriteReg8(0x200007e3, 0x1c);
	WriteReg8(0x200007e4, 0x1c);
	WriteReg8(0x200007e5, 0x1e);
	WriteReg8(0x200007e6, 0x1f);
	WriteReg8(0x200007e7, 0x21);
	WriteReg8(0x200007e8, 0x20);
	WriteReg8(0x200007e9, 0x1e);
	WriteReg8(0x200007ea, 0x1d);
	WriteReg8(0x200007eb, 0x1c);
	WriteReg8(0x200007ec, 0x1c);
	WriteReg8(0x200007ed, 0x1d);
	WriteReg8(0x200007ee, 0x1d);
	WriteReg8(0x200007ef, 0x1e);
	WriteReg8(0x200007f0, 0x1e);
	WriteReg8(0x200007f1, 0x1d);
	WriteReg8(0x200007f2, 0x1c);
	WriteReg8(0x200007f3, 0x1b);
	WriteReg8(0x200007f4, 0x1b);
	WriteReg8(0x200007f5, 0x1c);
	WriteReg8(0x200007f6, 0x1d);
	WriteReg8(0x200007f7, 0x1d);
	WriteReg8(0x200007f8, 0x1d);
	WriteReg8(0x200007f9, 0x1c);
	WriteReg8(0x200007fa, 0x1b);
	WriteReg8(0x200007fb, 0x1b);
	WriteReg8(0x200007fc, 0x1d);
	WriteReg8(0x200007fd, 0x1b);
	WriteReg8(0x200007fe, 0x1c);
	WriteReg8(0x200007ff, 0x1c);
	WriteReg8(0x20000800, 0x1c);
	WriteReg8(0x20000801, 0x1b);
	WriteReg8(0x20000802, 0x1b);
	WriteReg8(0x20000803, 0x19);
	WriteReg8(0x20000804, 0x24);
	WriteReg8(0x20000805, 0x20);
	WriteReg8(0x20000806, 0x21);
	WriteReg8(0x20000807, 0x20);
	WriteReg8(0x20000808, 0x21);
	WriteReg8(0x20000809, 0x21);
	WriteReg8(0x2000080a, 0x21);
	WriteReg8(0x2000080b, 0x25);
	WriteReg8(0x2000080c, 0x21);
	WriteReg8(0x2000080d, 0x22);
	WriteReg8(0x2000080e, 0x20);
	WriteReg8(0x2000080f, 0x21);
	WriteReg8(0x20000810, 0x20);
	WriteReg8(0x20000811, 0x21);
	WriteReg8(0x20000812, 0x22);
	WriteReg8(0x20000813, 0x22);
	WriteReg8(0x20000814, 0x20);
	WriteReg8(0x20000815, 0x21);
	WriteReg8(0x20000816, 0x20);
	WriteReg8(0x20000817, 0x20);
	WriteReg8(0x20000818, 0x20);
	WriteReg8(0x20000819, 0x21);
	WriteReg8(0x2000081a, 0x22);
	WriteReg8(0x2000081b, 0x20);
	WriteReg8(0x2000081c, 0x1f);
	WriteReg8(0x2000081d, 0x20);
	WriteReg8(0x2000081e, 0x20);
	WriteReg8(0x2000081f, 0x20);
	WriteReg8(0x20000820, 0x20);
	WriteReg8(0x20000821, 0x20);
	WriteReg8(0x20000822, 0x21);
	WriteReg8(0x20000823, 0x21);
	WriteReg8(0x20000824, 0x1e);
	WriteReg8(0x20000825, 0x20);
	WriteReg8(0x20000826, 0x20);
	WriteReg8(0x20000827, 0x20);
	WriteReg8(0x20000828, 0x20);
	WriteReg8(0x20000829, 0x21);
	WriteReg8(0x2000082a, 0x21);
	WriteReg8(0x2000082b, 0x21);
	WriteReg8(0x2000082c, 0x20);
	WriteReg8(0x2000082d, 0x22);
	WriteReg8(0x2000082e, 0x21);
	WriteReg8(0x2000082f, 0x22);
	WriteReg8(0x20000830, 0x22);
	WriteReg8(0x20000831, 0x22);
	WriteReg8(0x20000832, 0x23);
	WriteReg8(0x20000833, 0x22);
	WriteReg8(0x20000834, 0x22);
	WriteReg8(0x20000835, 0x23);
	WriteReg8(0x20000836, 0x22);
	WriteReg8(0x20000837, 0x22);
	WriteReg8(0x20000838, 0x22);
	WriteReg8(0x20000839, 0x23);
	WriteReg8(0x2000083a, 0x24);
	WriteReg8(0x2000083b, 0x22);
	WriteReg8(0x2000083c, 0x21);
	WriteReg8(0x2000083d, 0x20);
	WriteReg8(0x2000083e, 0x21);
	WriteReg8(0x2000083f, 0x22);
	WriteReg8(0x20000840, 0x21);
	WriteReg8(0x20000841, 0x22);
	WriteReg8(0x20000842, 0x20);
	WriteReg8(0x20000843, 0x29);

}


///////////////////////////////////////////////////////////////////////////////
//Function : AWB
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  AWB_cfg (unsigned char hdr_mode)
{
	fprintf(setting,"//awb_long\n");
	WriteReg8(0x20000440, 0x01);//AWB_mode
	WriteReg8(0x20000442, 0x01);//AWB_fleximap_en
	WriteReg8(0x20000452, 0x10);//min_num_L
	WriteReg8(0x20000453, 0x00);
	WriteReg8(0x20000458, 0xff);//max_awb_gain
	WriteReg8(0x20000459, 0x0f);
	WriteReg8(0x2000045e, 0x04);//awb_step
	WriteReg8(0x2000045f, 0x80);//max_step_value
	fprintf(setting,"\n");
	WriteReg8(0x200004d8, 0x19);//B_temp//don't_modify
	WriteReg8(0x200004d9, 0x06);//don't_modify
	WriteReg8(0x200004dc, 0x00);//G_temp//don't_modify
	WriteReg8(0x200004dd, 0x04);//don't_modify
	WriteReg8(0x200004e0, 0xc4);//R_temp//don't_modify
	WriteReg8(0x200004e1, 0x07);//don't_modify
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0708, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x0709, 0xf0);//pixel_max_value
	WriteReg8(ISP0_BASE_ADDR+0x070a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x070b, 0x0c);//pixel_min_value
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0730, 0x4f);
	WriteReg8(ISP0_BASE_ADDR+0x0731, 0x68);
	WriteReg8(ISP0_BASE_ADDR+0x0732, 0x62);
	WriteReg8(ISP0_BASE_ADDR+0x0733, 0x8a);//win0
	WriteReg8(ISP0_BASE_ADDR+0x0734, 0x70);
	WriteReg8(ISP0_BASE_ADDR+0x0735, 0x94);
	WriteReg8(ISP0_BASE_ADDR+0x0736, 0x58);
	WriteReg8(ISP0_BASE_ADDR+0x0737, 0x72);//win1
	WriteReg8(ISP0_BASE_ADDR+0x0738, 0x68);
	WriteReg8(ISP0_BASE_ADDR+0x0739, 0x88);
	WriteReg8(ISP0_BASE_ADDR+0x073a, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x073b, 0x60);//win2
	WriteReg8(ISP0_BASE_ADDR+0x073c, 0x82);
	WriteReg8(ISP0_BASE_ADDR+0x073d, 0xb0);
	WriteReg8(ISP0_BASE_ADDR+0x073e, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x073f, 0x51);//win3
	WriteReg8(ISP0_BASE_ADDR+0x0740, 0x56);
	WriteReg8(ISP0_BASE_ADDR+0x0741, 0x74);
	WriteReg8(ISP0_BASE_ADDR+0x0742, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x0743, 0x9a);//win4
	WriteReg8(ISP0_BASE_ADDR+0x0744, 0x5c);
	WriteReg8(ISP0_BASE_ADDR+0x0745, 0x7a);
	WriteReg8(ISP0_BASE_ADDR+0x0746, 0x5e);
	WriteReg8(ISP0_BASE_ADDR+0x0747, 0x81);//win5
	WriteReg8(ISP0_BASE_ADDR+0x0748, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0749, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x074a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x074b, 0x00);//win6
	WriteReg8(ISP0_BASE_ADDR+0x074c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x074d, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x074e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x074f, 0x00);//win7
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0770, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x0771, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x0772, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x0773, 0x00);//weight
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0750, 0x78);
	WriteReg8(ISP0_BASE_ADDR+0x0751, 0xf0);
	WriteReg8(ISP0_BASE_ADDR+0x0752, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x0753, 0x30);//redlight_win

	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		fprintf(setting,"//awb_short\n");
		WriteReg8(0x20000454, 0x08);//min_num_S
		WriteReg8(0x20000455, 0x00);
		WriteReg8(0x2000045a, 0xff);//max_awb_gain_S
		WriteReg8(0x2000045b, 0x0f);
		fprintf(setting,"\n");
		WriteReg8(0x200004e4, 0x00);//B_temp_S//don't_modify
		WriteReg8(0x200004e5, 0x04);//don't_modify
		WriteReg8(0x200004e8, 0x00);//G_temp_S//don't_modify
		WriteReg8(0x200004e9, 0x04);//don't_modify
		WriteReg8(0x200004ec, 0x00);//R_temp_S//don't_modify
		WriteReg8(0x200004ed, 0x04);//don't_modify
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4508, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x4509, 0xa0); //pixel_max_value
		WriteReg8(ISP0_BASE_ADDR+0x450a, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x450b, 0x04); //pixel_min_value
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4530, 0x4a);
		WriteReg8(ISP0_BASE_ADDR+0x4531, 0x7f);
		WriteReg8(ISP0_BASE_ADDR+0x4532, 0x65);
		WriteReg8(ISP0_BASE_ADDR+0x4533, 0xaf); //win0
		WriteReg8(ISP0_BASE_ADDR+0x4534, 0x6d);
		WriteReg8(ISP0_BASE_ADDR+0x4535, 0xa8);
		WriteReg8(ISP0_BASE_ADDR+0x4536, 0x50);
		WriteReg8(ISP0_BASE_ADDR+0x4537, 0x95); //win1
		WriteReg8(ISP0_BASE_ADDR+0x4538, 0x77);
		WriteReg8(ISP0_BASE_ADDR+0x4539, 0xa0);
		WriteReg8(ISP0_BASE_ADDR+0x453a, 0x3f);
		WriteReg8(ISP0_BASE_ADDR+0x453b, 0x78); //win2
		WriteReg8(ISP0_BASE_ADDR+0x453c, 0xc0);
		WriteReg8(ISP0_BASE_ADDR+0x453d, 0xd8);
		WriteReg8(ISP0_BASE_ADDR+0x453e, 0x34);
		WriteReg8(ISP0_BASE_ADDR+0x453f, 0x4f); //win3
		WriteReg8(ISP0_BASE_ADDR+0x4540, 0x9f);
		WriteReg8(ISP0_BASE_ADDR+0x4541, 0xc2);
		WriteReg8(ISP0_BASE_ADDR+0x4542, 0x3a);
		WriteReg8(ISP0_BASE_ADDR+0x4543, 0x6a); //win4
		WriteReg8(ISP0_BASE_ADDR+0x4544, 0x30);
		WriteReg8(ISP0_BASE_ADDR+0x4545, 0x55);
		WriteReg8(ISP0_BASE_ADDR+0x4546, 0x35);
		WriteReg8(ISP0_BASE_ADDR+0x4547, 0x63); //win5
		WriteReg8(ISP0_BASE_ADDR+0x4548, 0x85);
		WriteReg8(ISP0_BASE_ADDR+0x4549, 0xb0);
		WriteReg8(ISP0_BASE_ADDR+0x454a, 0x75);
		WriteReg8(ISP0_BASE_ADDR+0x454b, 0xb0); //win6
		WriteReg8(ISP0_BASE_ADDR+0x454c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x454d, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x454e, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x454f, 0x00); //win7
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4570, 0x11);
		WriteReg8(ISP0_BASE_ADDR+0x4571, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x4572, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x4573, 0x20); //weight	
	}

	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		fprintf(setting,"//awb_vs\n");	
		WriteReg8(0x20000456, 0x08);//min_num_VS
		WriteReg8(0x20000457, 0x00);
		WriteReg8(0x2000045c, 0xff);//max_awb_gain_VS
		WriteReg8(0x2000045d, 0x0f);
		fprintf(setting,"\n");
		WriteReg8(0x200004f0, 0x00);//B_temp_VS//don't_modify
		WriteReg8(0x200004f1, 0x04);//don't_modify
		WriteReg8(0x200004f4, 0x00);//G_temp_VS//don't_modify
		WriteReg8(0x200004f5, 0x04);//don't_modify
		WriteReg8(0x200004f8, 0x00);//R_temp_VS//don't_modify
		WriteReg8(0x200004f9, 0x04);//don't_modify
  	fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4708, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x4709, 0xa0); //pixel_max_value
		WriteReg8(ISP0_BASE_ADDR+0x470a, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x470b, 0x04); //pixel_min_value
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4730, 0x4a);
		WriteReg8(ISP0_BASE_ADDR+0x4731, 0x7f);
		WriteReg8(ISP0_BASE_ADDR+0x4732, 0x65);
		WriteReg8(ISP0_BASE_ADDR+0x4733, 0xaf); //win0
		WriteReg8(ISP0_BASE_ADDR+0x4734, 0x6d);
		WriteReg8(ISP0_BASE_ADDR+0x4735, 0xa8);
		WriteReg8(ISP0_BASE_ADDR+0x4736, 0x50);
		WriteReg8(ISP0_BASE_ADDR+0x4737, 0x95); //win1
		WriteReg8(ISP0_BASE_ADDR+0x4738, 0x77);
		WriteReg8(ISP0_BASE_ADDR+0x4739, 0xa0);
		WriteReg8(ISP0_BASE_ADDR+0x473a, 0x3f);
		WriteReg8(ISP0_BASE_ADDR+0x473b, 0x78); //win2
		WriteReg8(ISP0_BASE_ADDR+0x473c, 0xc0);
		WriteReg8(ISP0_BASE_ADDR+0x473d, 0xd8);
		WriteReg8(ISP0_BASE_ADDR+0x473e, 0x34);
		WriteReg8(ISP0_BASE_ADDR+0x473f, 0x4f); //win3
		WriteReg8(ISP0_BASE_ADDR+0x4740, 0x9f);
		WriteReg8(ISP0_BASE_ADDR+0x4741, 0xc2);
		WriteReg8(ISP0_BASE_ADDR+0x4742, 0x3a);
		WriteReg8(ISP0_BASE_ADDR+0x4743, 0x6a); //win4
		WriteReg8(ISP0_BASE_ADDR+0x4744, 0x30);
		WriteReg8(ISP0_BASE_ADDR+0x4745, 0x55);
		WriteReg8(ISP0_BASE_ADDR+0x4746, 0x35);
		WriteReg8(ISP0_BASE_ADDR+0x4747, 0x63); //win5
		WriteReg8(ISP0_BASE_ADDR+0x4748, 0x85);
		WriteReg8(ISP0_BASE_ADDR+0x4749, 0xb0);
		WriteReg8(ISP0_BASE_ADDR+0x474a, 0x75);
		WriteReg8(ISP0_BASE_ADDR+0x474b, 0xb0); //win6
		WriteReg8(ISP0_BASE_ADDR+0x474c, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x474d, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x474e, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x474f, 0x00); //win7
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x4770, 0x11);
		WriteReg8(ISP0_BASE_ADDR+0x4771, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x4772, 0x21);
		WriteReg8(ISP0_BASE_ADDR+0x4773, 0x20); //weight
	}
	
}


///////////////////////////////////////////////////////////////////////////////
//Function : HDR
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  HDR_cfg (unsigned char hdr_mode)
{
	if (hdr_mode ==3) {
		WriteReg8(ISP0_BASE_ADDR+0x0013, 0xc0);//combine_mode
	}
	else {
		WriteReg8(ISP0_BASE_ADDR+0x0013, 0x80);//combine_mode
	}
	fprintf(setting,"\n");
	//WriteReg8(ISP0_BASE_ADDR+0x0094, 0x83);
	//WriteReg8(ISP0_BASE_ADDR+0x00bc, 0xff);
	WriteReg8(ISP0_BASE_ADDR+0x00bd, 0x89);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2638, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2639, 0x00);//node
	WriteReg8(ISP0_BASE_ADDR+0x263a, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x263b, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x263c, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x263d, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x263e, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x263f, 0x00);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2640, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2641, 0x00);//offset
	WriteReg8(ISP0_BASE_ADDR+0x2642, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2643, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2644, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x2645, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2646, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x2647, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2648, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x2649, 0x00);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x264a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x264b, 0x00);//gain
	WriteReg8(ISP0_BASE_ADDR+0x264c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x264d, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x264e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x264f, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2650, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2651, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x2652, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2653, 0x20);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2500, 0x40);//scene_thr_L
	WriteReg8(ISP0_BASE_ADDR+0x2501, 0x40);//scene_thr_S
	WriteReg8(ISP0_BASE_ADDR+0x2502, 0x08);//scene_frame_num
	WriteReg8(ISP0_BASE_ADDR+0x2503, 0x01);//recognition mode
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2603, 0x80);//combine_thr
	WriteReg8(ISP0_BASE_ADDR+0x2604, 0x90);
	WriteReg8(ISP0_BASE_ADDR+0x2600, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x2601, 0x70);
	
	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x2658, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2659, 0x90);
		WriteReg8(ISP0_BASE_ADDR+0x2606, 0x30);
		WriteReg8(ISP0_BASE_ADDR+0x2607, 0x60);		
	}

	//WriteReg8(ISP0_BASE_ADDR+0x267f, 0x10);//combine_weight_man_en
	//WriteReg8(ISP0_BASE_ADDR+0x2680, 0x40);
	fprintf(setting,"\n");
	fprintf(setting,"//combine_weight\n");	
	WriteReg8(ISP0_BASE_ADDR+0x2609, 0x80);//combine_weight
	WriteReg8(ISP0_BASE_ADDR+0x260a, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x260b, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x260c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x260d, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x260e, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x260f, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2610, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x2611, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2612, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2613, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x2614, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2615, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2616, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2617, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2618, 0x00);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2619, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x261a, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x261b, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x261c, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x261d, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x261e, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x261f, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x2620, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2621, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2622, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2623, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2624, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2625, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2626, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2627, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2628, 0x00);
	
	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x265b, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x265c, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x265d, 0x40);
		WriteReg8(ISP0_BASE_ADDR+0x265e, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x265f, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2660, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2661, 0x20);
		WriteReg8(ISP0_BASE_ADDR+0x2662, 0x10);
		WriteReg8(ISP0_BASE_ADDR+0x2663, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2664, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2665, 0x10);
		WriteReg8(ISP0_BASE_ADDR+0x2666, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x2667, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2668, 0x80);
		WriteReg8(ISP0_BASE_ADDR+0x2669, 0x00);
		WriteReg8(ISP0_BASE_ADDR+0x266a, 0x00);
	}
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x266b, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x266c, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x266d, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x266e, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x266f, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2670, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2671, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x2672, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2673, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2674, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2675, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2676, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2677, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2678, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2679, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x267a, 0x00);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2629, 0xff);//ratio
	WriteReg8(ISP0_BASE_ADDR+0x262a, 0xff);
	WriteReg8(ISP0_BASE_ADDR+0x262b, 0x96);
	WriteReg8(ISP0_BASE_ADDR+0x262c, 0x96);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x262d, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x262e, 0x00);//compression
	WriteReg8(ISP0_BASE_ADDR+0x262f, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x2630, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2631, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x2632, 0x00);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2633, 0x34);
	WriteReg8(ISP0_BASE_ADDR+0x2634, 0x00);//comb_limit
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x268e, 0x01);//expo_ratio_ls: FW mode
	WriteReg8(ISP0_BASE_ADDR+0x268f, 0x01);//expo_ratio_sv: FW mode
	WriteReg8(ISP0_BASE_ADDR+0x2694, 0x01);//prefer L: enable, weight_L:[(128 - [ISP0_BASE_ADDR+0x2695]) * weight_hw + [ISP0_BASE_ADDR+0x2695] * 128] >> 8, weight_S:128 - weight_L
	//WriteReg8(ISP0_BASE_ADDR+0x2695, 0x50);//FW calculate, strength of prefer L
	WriteReg8(ISP0_BASE_ADDR+0x2686, 0x01);//expo_ratio: IIR enable
	WriteReg8(ISP0_BASE_ADDR+0x2687, 0x80);//expo_ratio: IIR speed
	WriteReg8(ISP0_BASE_ADDR+0x2688, 0x08);//expo_ratio: IIR step
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2700, 0x06);//bit[1]:normalize_manual_en
	WriteReg8(ISP0_BASE_ADDR+0x270a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x270b, 0x20);//offset_manual
	WriteReg8(ISP0_BASE_ADDR+0x270c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x270d, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x270e, 0x00);//gain_manual
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2800, 0x07);//bit[1]:histsmooth_en; bit[0]:dither_en
	WriteReg8(ISP0_BASE_ADDR+0x2801, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x2802, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2803, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x2804, 0x00);	
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2814, 0x01);//tone_mapping: modification enable
	WriteReg8(ISP0_BASE_ADDR+0x2815, 0x01);//tone_mapping: IIR enable
	WriteReg8(ISP0_BASE_ADDR+0x2816, 0x80);//tone_mapping: IIR speed
	WriteReg8(ISP0_BASE_ADDR+0x2817, 0x03);//tone_mapping: IIR step
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x268b, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x2635, 0xd4);//ratio_highlight
	WriteReg8(ISP0_BASE_ADDR+0x2636, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2637, 0x64);//portion_highlight
	fprintf(setting,"\n");
	fprintf(setting,"//gamma_gain\n");	
	WriteReg8(ISP0_BASE_ADDR+0x2900, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2901, 0x00);//gamma_gain00
	WriteReg8(ISP0_BASE_ADDR+0x2902, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2903, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2904, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2905, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x2906, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2907, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2908, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2909, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x290a, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x290b, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x290c, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x290d, 0x6e);
	WriteReg8(ISP0_BASE_ADDR+0x290e, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x290f, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2910, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2911, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x2912, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2913, 0x66);
	WriteReg8(ISP0_BASE_ADDR+0x2914, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2915, 0x74);
	WriteReg8(ISP0_BASE_ADDR+0x2916, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2917, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x2918, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2919, 0x62);
	WriteReg8(ISP0_BASE_ADDR+0x291a, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x291b, 0x49);
	WriteReg8(ISP0_BASE_ADDR+0x291c, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x291d, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x291e, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x291f, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x2920, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2921, 0x2d);
	WriteReg8(ISP0_BASE_ADDR+0x2922, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2923, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x2924, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2925, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x2926, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2927, 0x1a);
	WriteReg8(ISP0_BASE_ADDR+0x2928, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x2929, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x292a, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x292b, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x292c, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x292d, 0xf5);
	WriteReg8(ISP0_BASE_ADDR+0x292e, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x292f, 0xd5);
	WriteReg8(ISP0_BASE_ADDR+0x2930, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2931, 0xcd);
	WriteReg8(ISP0_BASE_ADDR+0x2932, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2933, 0xc5);
	WriteReg8(ISP0_BASE_ADDR+0x2934, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2935, 0xbe);
	WriteReg8(ISP0_BASE_ADDR+0x2936, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2937, 0xa5);
	WriteReg8(ISP0_BASE_ADDR+0x2938, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2939, 0x9f);
	WriteReg8(ISP0_BASE_ADDR+0x293a, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x293b, 0x89);
	WriteReg8(ISP0_BASE_ADDR+0x293c, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x293d, 0x84);
	WriteReg8(ISP0_BASE_ADDR+0x293e, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x293f, 0x70);
	WriteReg8(ISP0_BASE_ADDR+0x2940, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2941, 0x5a);
	WriteReg8(ISP0_BASE_ADDR+0x2942, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2943, 0x47);
	WriteReg8(ISP0_BASE_ADDR+0x2944, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2945, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x2946, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x2947, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x2948, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2949, 0xf4);
	WriteReg8(ISP0_BASE_ADDR+0x294a, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x294b, 0xdd);
	WriteReg8(ISP0_BASE_ADDR+0x294c, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x294d, 0xc8);
	WriteReg8(ISP0_BASE_ADDR+0x294e, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x294f, 0xab);
	WriteReg8(ISP0_BASE_ADDR+0x2950, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2951, 0x9a);
	WriteReg8(ISP0_BASE_ADDR+0x2952, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2953, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x2954, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2955, 0x68);
	WriteReg8(ISP0_BASE_ADDR+0x2956, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2957, 0x5b);
	WriteReg8(ISP0_BASE_ADDR+0x2958, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x2959, 0x47);
	WriteReg8(ISP0_BASE_ADDR+0x295a, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x295b, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x295c, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x295d, 0x21);
	WriteReg8(ISP0_BASE_ADDR+0x295e, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x295f, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x2960, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2961, 0xe9);
	WriteReg8(ISP0_BASE_ADDR+0x2962, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2963, 0xc7);
	WriteReg8(ISP0_BASE_ADDR+0x2964, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2965, 0xa8);
	WriteReg8(ISP0_BASE_ADDR+0x2966, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2967, 0x8d);
	WriteReg8(ISP0_BASE_ADDR+0x2968, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2969, 0x7a);
	WriteReg8(ISP0_BASE_ADDR+0x296a, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x296b, 0x63);
	WriteReg8(ISP0_BASE_ADDR+0x296c, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x296d, 0x4e);
	WriteReg8(ISP0_BASE_ADDR+0x296e, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x296f, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x2970, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2971, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x2972, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2973, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x2974, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2975, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x2976, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2977, 0x17);
	WriteReg8(ISP0_BASE_ADDR+0x2978, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x2979, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x297a, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x297b, 0x09);
	WriteReg8(ISP0_BASE_ADDR+0x297c, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x297d, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x297e, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x297f, 0x00);//gamma_gain63
	fprintf(setting,"\n");
	fprintf(setting,"//gamma_table\n");	
	WriteReg8(ISP0_BASE_ADDR+0x2980, 0x3e);
	WriteReg8(ISP0_BASE_ADDR+0x2981, 0x00);//slope_table00
	WriteReg8(ISP0_BASE_ADDR+0x2982, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2983, 0x56);
	WriteReg8(ISP0_BASE_ADDR+0x2984, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2985, 0xaa);
	WriteReg8(ISP0_BASE_ADDR+0x2986, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2987, 0x9a);
	WriteReg8(ISP0_BASE_ADDR+0x2988, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2989, 0xbc);
	WriteReg8(ISP0_BASE_ADDR+0x298a, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x298b, 0xce);
	WriteReg8(ISP0_BASE_ADDR+0x298c, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x298d, 0xdc);
	WriteReg8(ISP0_BASE_ADDR+0x298e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x298f, 0x56);
	WriteReg8(ISP0_BASE_ADDR+0x2990, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2991, 0xde);
	WriteReg8(ISP0_BASE_ADDR+0x2992, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2993, 0xe4);
	WriteReg8(ISP0_BASE_ADDR+0x2994, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2995, 0x3e);
	WriteReg8(ISP0_BASE_ADDR+0x2996, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x2997, 0xe6);
	WriteReg8(ISP0_BASE_ADDR+0x2998, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2999, 0x32);
	WriteReg8(ISP0_BASE_ADDR+0x299a, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x299b, 0xe8);
	WriteReg8(ISP0_BASE_ADDR+0x299c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x299d, 0x2a);
	WriteReg8(ISP0_BASE_ADDR+0x299e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x299f, 0x26);
	WriteReg8(ISP0_BASE_ADDR+0x29a0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29a1, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x29a2, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x29a3, 0xe8);
	WriteReg8(ISP0_BASE_ADDR+0x29a4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29a5, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x29a6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29a7, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x29a8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29a9, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x29aa, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29ab, 0x16);
	WriteReg8(ISP0_BASE_ADDR+0x29ac, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29ad, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x29ae, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29af, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x29b0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29b1, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x29b2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29b3, 0x0e);
	WriteReg8(ISP0_BASE_ADDR+0x29b4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29b5, 0x32);
	WriteReg8(ISP0_BASE_ADDR+0x29b6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29b7, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x29b8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29b9, 0x2c);
	WriteReg8(ISP0_BASE_ADDR+0x29ba, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29bb, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x29bc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29bd, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x29be, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29bf, 0x16);
	WriteReg8(ISP0_BASE_ADDR+0x29c0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29c1, 0x13);
	WriteReg8(ISP0_BASE_ADDR+0x29c2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29c3, 0x1f);
	WriteReg8(ISP0_BASE_ADDR+0x29c4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29c5, 0x1b);
	WriteReg8(ISP0_BASE_ADDR+0x29c6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29c7, 0x19);
	WriteReg8(ISP0_BASE_ADDR+0x29c8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29c9, 0x17);
	WriteReg8(ISP0_BASE_ADDR+0x29ca, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29cb, 0x15);
	WriteReg8(ISP0_BASE_ADDR+0x29cc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29cd, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x29ce, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29cf, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x29d0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29d1, 0x1a);
	WriteReg8(ISP0_BASE_ADDR+0x29d2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29d3, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x29d4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29d5, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x29d6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29d7, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x29d8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29d9, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x29da, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29db, 0x12);
	WriteReg8(ISP0_BASE_ADDR+0x29dc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29dd, 0x19);
	WriteReg8(ISP0_BASE_ADDR+0x29de, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29df, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x29e0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29e1, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x29e2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29e3, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x29e4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29e5, 0x0e);
	WriteReg8(ISP0_BASE_ADDR+0x29e6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29e7, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x29e8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29e9, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x29ea, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29eb, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x29ec, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29ed, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x29ee, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29ef, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x29f0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29f1, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x29f2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29f3, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x29f4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29f5, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x29f6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29f7, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x29f8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29f9, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x29fa, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29fb, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x29fc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29fd, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x29fe, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x29ff, 0x00);//slope_table63
}


///////////////////////////////////////////////////////////////////////////////
//Function : RAW_gamma
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  Raw_gamma_cfg (void)
{
	fprintf(setting,"//Raw_Gamma\n");
	WriteReg8(ISP0_BASE_ADDR+0x0900, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0901, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x0902, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0903, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x0904, 0x09);
	WriteReg8(ISP0_BASE_ADDR+0x0905, 0x0C);
	WriteReg8(ISP0_BASE_ADDR+0x0906, 0x0E);
	WriteReg8(ISP0_BASE_ADDR+0x0907, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x0908, 0x13);
	WriteReg8(ISP0_BASE_ADDR+0x0909, 0x16);
	WriteReg8(ISP0_BASE_ADDR+0x090a, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x090b, 0x1B);
	WriteReg8(ISP0_BASE_ADDR+0x090c, 0x1D);
	WriteReg8(ISP0_BASE_ADDR+0x090d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x090e, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x090f, 0x25);
	WriteReg8(ISP0_BASE_ADDR+0x0910, 0x27);
	WriteReg8(ISP0_BASE_ADDR+0x0911, 0x2A);
	WriteReg8(ISP0_BASE_ADDR+0x0912, 0x2C);
	WriteReg8(ISP0_BASE_ADDR+0x0913, 0x2F);
	WriteReg8(ISP0_BASE_ADDR+0x0914, 0x31);
	WriteReg8(ISP0_BASE_ADDR+0x0915, 0x34);
	WriteReg8(ISP0_BASE_ADDR+0x0916, 0x36);
	WriteReg8(ISP0_BASE_ADDR+0x0917, 0x39);
	WriteReg8(ISP0_BASE_ADDR+0x0918, 0x3C);
	WriteReg8(ISP0_BASE_ADDR+0x0919, 0x3E);
	WriteReg8(ISP0_BASE_ADDR+0x091a, 0x41);
	WriteReg8(ISP0_BASE_ADDR+0x091b, 0x43);
	WriteReg8(ISP0_BASE_ADDR+0x091c, 0x46);
	WriteReg8(ISP0_BASE_ADDR+0x091d, 0x48);
	WriteReg8(ISP0_BASE_ADDR+0x091e, 0x4B);
	WriteReg8(ISP0_BASE_ADDR+0x091f, 0x4D);
	WriteReg8(ISP0_BASE_ADDR+0x0920, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x0921, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x0922, 0x5A);
	WriteReg8(ISP0_BASE_ADDR+0x0923, 0x5E);
	WriteReg8(ISP0_BASE_ADDR+0x0924, 0x62);
	WriteReg8(ISP0_BASE_ADDR+0x0925, 0x66);
	WriteReg8(ISP0_BASE_ADDR+0x0926, 0x6A);
	WriteReg8(ISP0_BASE_ADDR+0x0927, 0x6E);
	WriteReg8(ISP0_BASE_ADDR+0x0928, 0x72);
	WriteReg8(ISP0_BASE_ADDR+0x0929, 0x76);
	WriteReg8(ISP0_BASE_ADDR+0x092a, 0x79);
	WriteReg8(ISP0_BASE_ADDR+0x092b, 0x7D);
	WriteReg8(ISP0_BASE_ADDR+0x092c, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x092d, 0x83);
	WriteReg8(ISP0_BASE_ADDR+0x092e, 0x87);
	WriteReg8(ISP0_BASE_ADDR+0x092f, 0x8A);
	WriteReg8(ISP0_BASE_ADDR+0x0930, 0x8D);
	WriteReg8(ISP0_BASE_ADDR+0x0931, 0x94);
	WriteReg8(ISP0_BASE_ADDR+0x0932, 0x9B);
	WriteReg8(ISP0_BASE_ADDR+0x0933, 0xA1);
	WriteReg8(ISP0_BASE_ADDR+0x0934, 0xA8);
	WriteReg8(ISP0_BASE_ADDR+0x0935, 0xAF);
	WriteReg8(ISP0_BASE_ADDR+0x0936, 0xB6);
	WriteReg8(ISP0_BASE_ADDR+0x0937, 0xBD);
	WriteReg8(ISP0_BASE_ADDR+0x0938, 0xC4);
	WriteReg8(ISP0_BASE_ADDR+0x0939, 0xCB);
	WriteReg8(ISP0_BASE_ADDR+0x093a, 0xD3);
	WriteReg8(ISP0_BASE_ADDR+0x093b, 0xDA);
	WriteReg8(ISP0_BASE_ADDR+0x093c, 0xE1);
	WriteReg8(ISP0_BASE_ADDR+0x093d, 0xE9);
	WriteReg8(ISP0_BASE_ADDR+0x093e, 0xF0);
	WriteReg8(ISP0_BASE_ADDR+0x093f, 0xF8);
	WriteReg8(ISP0_BASE_ADDR+0x0940, 0xFE);
}


///////////////////////////////////////////////////////////////////////////////
//Function : RGB_gamma
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  Rgb_gamma_cfg (void)
{
	fprintf(setting,"//Rgb_Gamma\n");
	WriteReg8(ISP0_BASE_ADDR+0x1400, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1401, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x1402, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x1403, 0x09);
	WriteReg8(ISP0_BASE_ADDR+0x1404, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x1405, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x1406, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x1407, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x1408, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x1409, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x140a, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x140b, 0x29);
	WriteReg8(ISP0_BASE_ADDR+0x140c, 0x2d);
	WriteReg8(ISP0_BASE_ADDR+0x140d, 0x32);
	WriteReg8(ISP0_BASE_ADDR+0x140e, 0x36);
	WriteReg8(ISP0_BASE_ADDR+0x140f, 0x3a);
	WriteReg8(ISP0_BASE_ADDR+0x1410, 0x3f);
	WriteReg8(ISP0_BASE_ADDR+0x1411, 0x42);
	WriteReg8(ISP0_BASE_ADDR+0x1412, 0x46);
	WriteReg8(ISP0_BASE_ADDR+0x1413, 0x49);
	WriteReg8(ISP0_BASE_ADDR+0x1414, 0x4d);
	WriteReg8(ISP0_BASE_ADDR+0x1415, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x1416, 0x53);
	WriteReg8(ISP0_BASE_ADDR+0x1417, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x1418, 0x58);
	WriteReg8(ISP0_BASE_ADDR+0x1419, 0x5b);
	WriteReg8(ISP0_BASE_ADDR+0x141a, 0x5e);
	WriteReg8(ISP0_BASE_ADDR+0x141b, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x141c, 0x63);
	WriteReg8(ISP0_BASE_ADDR+0x141d, 0x65);
	WriteReg8(ISP0_BASE_ADDR+0x141e, 0x68);
	WriteReg8(ISP0_BASE_ADDR+0x141f, 0x6a);
	WriteReg8(ISP0_BASE_ADDR+0x1420, 0x6d);
	WriteReg8(ISP0_BASE_ADDR+0x1421, 0x71);
	WriteReg8(ISP0_BASE_ADDR+0x1422, 0x76);
	WriteReg8(ISP0_BASE_ADDR+0x1423, 0x7a);
	WriteReg8(ISP0_BASE_ADDR+0x1424, 0x7e);
	WriteReg8(ISP0_BASE_ADDR+0x1425, 0x82);
	WriteReg8(ISP0_BASE_ADDR+0x1426, 0x85);
	WriteReg8(ISP0_BASE_ADDR+0x1427, 0x89);
	WriteReg8(ISP0_BASE_ADDR+0x1428, 0x8c);
	WriteReg8(ISP0_BASE_ADDR+0x1429, 0x8f);
	WriteReg8(ISP0_BASE_ADDR+0x142a, 0x92);
	WriteReg8(ISP0_BASE_ADDR+0x142b, 0x95);
	WriteReg8(ISP0_BASE_ADDR+0x142c, 0x98);
	WriteReg8(ISP0_BASE_ADDR+0x142d, 0x9b);
	WriteReg8(ISP0_BASE_ADDR+0x142e, 0x9e);
	WriteReg8(ISP0_BASE_ADDR+0x142f, 0xa1);
	WriteReg8(ISP0_BASE_ADDR+0x1430, 0xa3);
	WriteReg8(ISP0_BASE_ADDR+0x1431, 0xa9);
	WriteReg8(ISP0_BASE_ADDR+0x1432, 0xaf);
	WriteReg8(ISP0_BASE_ADDR+0x1433, 0xb4);
	WriteReg8(ISP0_BASE_ADDR+0x1434, 0xba);
	WriteReg8(ISP0_BASE_ADDR+0x1435, 0xc0);
	WriteReg8(ISP0_BASE_ADDR+0x1436, 0xc6);
	WriteReg8(ISP0_BASE_ADDR+0x1437, 0xcb);
	WriteReg8(ISP0_BASE_ADDR+0x1438, 0xd1);
	WriteReg8(ISP0_BASE_ADDR+0x1439, 0xd7);
	WriteReg8(ISP0_BASE_ADDR+0x143a, 0xdd);
	WriteReg8(ISP0_BASE_ADDR+0x143b, 0xe3);
	WriteReg8(ISP0_BASE_ADDR+0x143c, 0xe8);
	WriteReg8(ISP0_BASE_ADDR+0x143d, 0xee);
	WriteReg8(ISP0_BASE_ADDR+0x143e, 0xf4);
	WriteReg8(ISP0_BASE_ADDR+0x143f, 0xfa);
	WriteReg8(ISP0_BASE_ADDR+0x1440, 0xff);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x1450, 0xaa);
	WriteReg8(ISP0_BASE_ADDR+0x1451, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x1452, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x1453, 0x38);
}


///////////////////////////////////////////////////////////////////////////////
//Function : YUV_gamma
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  Yuv_gamma_cfg (void)
{
	fprintf(setting,"//Yuv_Gamma\n");
	WriteReg8(ISP0_BASE_ADDR+0x5300, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5301, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x5302, 0x0B);
	WriteReg8(ISP0_BASE_ADDR+0x5303, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x5304, 0x17);
	WriteReg8(ISP0_BASE_ADDR+0x5305, 0x1D);
	WriteReg8(ISP0_BASE_ADDR+0x5306, 0x22);
	WriteReg8(ISP0_BASE_ADDR+0x5307, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x5308, 0x2D);
	WriteReg8(ISP0_BASE_ADDR+0x5309, 0x31);
	WriteReg8(ISP0_BASE_ADDR+0x530a, 0x36);
	WriteReg8(ISP0_BASE_ADDR+0x530b, 0x3A);
	WriteReg8(ISP0_BASE_ADDR+0x530c, 0x3E);
	WriteReg8(ISP0_BASE_ADDR+0x530d, 0x41);
	WriteReg8(ISP0_BASE_ADDR+0x530e, 0x45);
	WriteReg8(ISP0_BASE_ADDR+0x530f, 0x48);
	WriteReg8(ISP0_BASE_ADDR+0x5310, 0x4C);
	WriteReg8(ISP0_BASE_ADDR+0x5311, 0x4F);
	WriteReg8(ISP0_BASE_ADDR+0x5312, 0x51);
	WriteReg8(ISP0_BASE_ADDR+0x5313, 0x54);
	WriteReg8(ISP0_BASE_ADDR+0x5314, 0x57);
	WriteReg8(ISP0_BASE_ADDR+0x5315, 0x59);
	WriteReg8(ISP0_BASE_ADDR+0x5316, 0x5C);
	WriteReg8(ISP0_BASE_ADDR+0x5317, 0x5E);
	WriteReg8(ISP0_BASE_ADDR+0x5318, 0x61);
	WriteReg8(ISP0_BASE_ADDR+0x5319, 0x63);
	WriteReg8(ISP0_BASE_ADDR+0x531a, 0x65);
	WriteReg8(ISP0_BASE_ADDR+0x531b, 0x67);
	WriteReg8(ISP0_BASE_ADDR+0x531c, 0x69);
	WriteReg8(ISP0_BASE_ADDR+0x531d, 0x6B);
	WriteReg8(ISP0_BASE_ADDR+0x531e, 0x6D);
	WriteReg8(ISP0_BASE_ADDR+0x531f, 0x70);
	WriteReg8(ISP0_BASE_ADDR+0x5320, 0x72);
	WriteReg8(ISP0_BASE_ADDR+0x5321, 0x75);
	WriteReg8(ISP0_BASE_ADDR+0x5322, 0x79);
	WriteReg8(ISP0_BASE_ADDR+0x5323, 0x7D);
	WriteReg8(ISP0_BASE_ADDR+0x5324, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x5325, 0x84);
	WriteReg8(ISP0_BASE_ADDR+0x5326, 0x87);
	WriteReg8(ISP0_BASE_ADDR+0x5327, 0x8A);
	WriteReg8(ISP0_BASE_ADDR+0x5328, 0x8E);
	WriteReg8(ISP0_BASE_ADDR+0x5329, 0x91);
	WriteReg8(ISP0_BASE_ADDR+0x532a, 0x94);
	WriteReg8(ISP0_BASE_ADDR+0x532b, 0x97);
	WriteReg8(ISP0_BASE_ADDR+0x532c, 0x9A);
	WriteReg8(ISP0_BASE_ADDR+0x532d, 0x9D);
	WriteReg8(ISP0_BASE_ADDR+0x532e, 0xA0);
	WriteReg8(ISP0_BASE_ADDR+0x532f, 0xA3);
	WriteReg8(ISP0_BASE_ADDR+0x5330, 0xA6);
	WriteReg8(ISP0_BASE_ADDR+0x5331, 0xAB);
	WriteReg8(ISP0_BASE_ADDR+0x5332, 0xB1);
	WriteReg8(ISP0_BASE_ADDR+0x5333, 0xB6);
	WriteReg8(ISP0_BASE_ADDR+0x5334, 0xBB);
	WriteReg8(ISP0_BASE_ADDR+0x5335, 0xC0);
	WriteReg8(ISP0_BASE_ADDR+0x5336, 0xC6);
	WriteReg8(ISP0_BASE_ADDR+0x5337, 0xCB);
	WriteReg8(ISP0_BASE_ADDR+0x5338, 0xD1);
	WriteReg8(ISP0_BASE_ADDR+0x5339, 0xD6);
	WriteReg8(ISP0_BASE_ADDR+0x533a, 0xDC);
	WriteReg8(ISP0_BASE_ADDR+0x533b, 0xE2);
	WriteReg8(ISP0_BASE_ADDR+0x533c, 0xE7);
	WriteReg8(ISP0_BASE_ADDR+0x533d, 0xED);
	WriteReg8(ISP0_BASE_ADDR+0x533e, 0xF3);
	WriteReg8(ISP0_BASE_ADDR+0x533f, 0xF9);
	WriteReg8(ISP0_BASE_ADDR+0x5340, 0xfe);
}


///////////////////////////////////////////////////////////////////////////////
//Function : CMX
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  CMX_cfg (void)
{
	WriteReg8(ISP0_BASE_ADDR+0x1200, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x1201, 0x6B);
	WriteReg8(ISP0_BASE_ADDR+0x1202, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1203, 0x64);
	WriteReg8(ISP0_BASE_ADDR+0x1204, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x1205, 0x12);
	WriteReg8(ISP0_BASE_ADDR+0x1206, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x1207, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x1208, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1209, 0xC1);
	WriteReg8(ISP0_BASE_ADDR+0x120a, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x120b, 0xE9);
	WriteReg8(ISP0_BASE_ADDR+0x120c, 0x70);
	WriteReg8(ISP0_BASE_ADDR+0x120d, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x120e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x120f, 0xAC);
	WriteReg8(ISP0_BASE_ADDR+0x1210, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x1211, 0x47);
	WriteReg8(ISP0_BASE_ADDR+0x1212, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x1213, 0x87);
	WriteReg8(ISP0_BASE_ADDR+0x1214, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x1215, 0x2D);
	WriteReg8(ISP0_BASE_ADDR+0x1216, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1217, 0xFA);
	WriteReg8(ISP0_BASE_ADDR+0x1218, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x1219, 0xF3);
	WriteReg8(ISP0_BASE_ADDR+0x121a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x121b, 0xF0);
	WriteReg8(ISP0_BASE_ADDR+0x121c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x121d, 0x55);
	WriteReg8(ISP0_BASE_ADDR+0x121e, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x121f, 0xB0);
	WriteReg8(ISP0_BASE_ADDR+0x1220, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1221, 0x46);
	WriteReg8(ISP0_BASE_ADDR+0x1222, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x1223, 0x7F);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x1228, 0x01);//cmx_ct_list
	WriteReg8(ISP0_BASE_ADDR+0x1229, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x122a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x122b, 0xc0);
	WriteReg8(ISP0_BASE_ADDR+0x122c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x122d, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x122e, 0x00);//sign
	WriteReg8(ISP0_BASE_ADDR+0x122f, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1230, 0x00);
	fprintf(setting,"\n");
	fprintf(setting,"//CMX_ctrl\n");	
	WriteReg8(ISP0_BASE_ADDR+0x1231, 0x03);//CMX_ctrl
	WriteReg8(ISP0_BASE_ADDR+0x1232, 0x44);
	WriteReg8(ISP0_BASE_ADDR+0x1233, 0x38);
	WriteReg8(ISP0_BASE_ADDR+0x1234, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x1235, 0x1f);
}


///////////////////////////////////////////////////////////////////////////////
//Function : NR3D
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  NR3D_cfg (void)
{
	WriteReg8(ISP0_BASE_ADDR+0x3c01, 0x5a);//wt_pedestal
	WriteReg8(ISP0_BASE_ADDR+0x3c04, 0x4c);//bit[6:4]erosion_num; bit[3]:erosion_en bit[2]:diff_mode
	WriteReg8(ISP0_BASE_ADDR+0x3c34, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x3c42, 0x2c);//cur_still_px_wt
	WriteReg8(ISP0_BASE_ADDR+0x3c43, 0x58);//cur_move_px_wt
	WriteReg8(ISP0_BASE_ADDR+0x3c4c, 0x5a);//max_move_px_wt
	WriteReg8(ISP0_BASE_ADDR+0x3c4d, 0x40);//move_diff_ratio
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c10, 0x00);//slope_lf_1x
	WriteReg8(ISP0_BASE_ADDR+0x3c11, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x3c12, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c13, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x3c14, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c15, 0x11);
	WriteReg8(ISP0_BASE_ADDR+0x3c16, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c17, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x3c18, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c19, 0x34);
	WriteReg8(ISP0_BASE_ADDR+0x3c1a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c1b, 0x76);
	WriteReg8(ISP0_BASE_ADDR+0x3c1c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c1d, 0xe2);
	WriteReg8(ISP0_BASE_ADDR+0x3c1e, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x3c1f, 0x96);
	WriteReg8(ISP0_BASE_ADDR+0x3c20, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x3c21, 0x91);//slope_lf_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c22, 0x00);//offset_lf_1x
	WriteReg8(ISP0_BASE_ADDR+0x3c23, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c24, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c25, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c26, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c27, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c28, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c29, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2b, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2d, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c2f, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c30, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c31, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c32, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c33, 0x00);//offset_lf_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3cba, 0x00);//slope_rt_1x
	WriteReg8(ISP0_BASE_ADDR+0x3cbb, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x3cbc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cbd, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x3cbe, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cbf, 0x07);
	WriteReg8(ISP0_BASE_ADDR+0x3cc0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cc1, 0x0b);
	WriteReg8(ISP0_BASE_ADDR+0x3cc2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cc3, 0x15);
	WriteReg8(ISP0_BASE_ADDR+0x3cc4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cc5, 0x2f);
	WriteReg8(ISP0_BASE_ADDR+0x3cc6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cc7, 0x5b);
	WriteReg8(ISP0_BASE_ADDR+0x3cc8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cc9, 0xa3);
	WriteReg8(ISP0_BASE_ADDR+0x3cca, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ccb, 0xa1);//slope_rt_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3ccc, 0x00);//offset_rt_1x
	WriteReg8(ISP0_BASE_ADDR+0x3ccd, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cce, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ccf, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd1, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd3, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd5, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd7, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cd9, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cda, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cdb, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cdc, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cdd, 0x00);//offset_rt_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3cde, 0x00);//limit_up_1x
	WriteReg8(ISP0_BASE_ADDR+0x3cdf, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x3ce0, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ce1, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x3ce2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ce3, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x3ce4, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ce5, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x3ce6, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ce7, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x3ce8, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ce9, 0x37);
	WriteReg8(ISP0_BASE_ADDR+0x3cea, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ceb, 0x6a);
	WriteReg8(ISP0_BASE_ADDR+0x3cec, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ced, 0xbe);
	WriteReg8(ISP0_BASE_ADDR+0x3cee, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3cef, 0xbc);//limit_up_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c90, 0x00);//dif_new_mode_wt_1x
	WriteReg8(ISP0_BASE_ADDR+0x3c91, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c92, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c93, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c94, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c95, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c96, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c97, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3c98, 0x00);//dif_new_mode_wt_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c99, 0x00);//dif_new_mode_wt_man
	WriteReg8(ISP0_BASE_ADDR+0x3c9a, 0x00);//dif_new_mode_wt_man_en
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3ca0, 0x57);//bit[6]:smooth_filter_en; bit[5:4]:dif_new_mode_sel; bit[3]:erosion2dilation_en; bit[2]:soft_thr_en; bit[1]:lap_enhancement_en; bit[0]:dif_new_mode_en
	WriteReg8(ISP0_BASE_ADDR+0x3ca1, 0x80);//dif_wt_lpf
	WriteReg8(ISP0_BASE_ADDR+0x3ca2, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x3ca3, 0x80);//med_filter_scale[8:0]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3ca4, 0x04);//soft_thr_slope_1x
	WriteReg8(ISP0_BASE_ADDR+0x3ca5, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x3ca6, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x3ca7, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x3ca8, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x3ca9, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x3caa, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x3cab, 0x38);
	WriteReg8(ISP0_BASE_ADDR+0x3cac, 0x48);//soft_thr_slope_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3cad, 0x00);//soft_thr_offset_1x
	WriteReg8(ISP0_BASE_ADDR+0x3cae, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x3caf, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x3cb0, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x3cb1, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x3cb2, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x3cb3, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x3cb4, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x3cb5, 0x20);//soft_thr_offset_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3cb6, 0x20);//soft_thr_slope_man
	WriteReg8(ISP0_BASE_ADDR+0x3cb7, 0x08);//soft_thr_offset_man
	WriteReg8(ISP0_BASE_ADDR+0x3cb8, 0x00);//bit[1]:soft_thr_offset_man_en; bit[0]:soft_thr_slope_man_en
	
	WriteReg8(ISP0_BASE_ADDR+0x3cb9, 0x08);//enhance_scale
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c54, 0x05);//mv_dns_adj_g_1x
	WriteReg8(ISP0_BASE_ADDR+0x3c55, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x3c56, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x3c57, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x3c58, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x3c59, 0x2c);
	WriteReg8(ISP0_BASE_ADDR+0x3c5a, 0x34);
	WriteReg8(ISP0_BASE_ADDR+0x3c5b, 0x3d);
	WriteReg8(ISP0_BASE_ADDR+0x3c5c, 0x3d);//mv_dns_adj_g_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c5d, 0x05);//st_dns_adj_g_1x
	WriteReg8(ISP0_BASE_ADDR+0x3c5e, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x3c5f, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x3c60, 0x1d);
	WriteReg8(ISP0_BASE_ADDR+0x3c61, 0x23);
	WriteReg8(ISP0_BASE_ADDR+0x3c62, 0x2c);
	WriteReg8(ISP0_BASE_ADDR+0x3c63, 0x34);
	WriteReg8(ISP0_BASE_ADDR+0x3c64, 0x3d);
	WriteReg8(ISP0_BASE_ADDR+0x3c65, 0x3d);//st_dns_adj_g_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x3c53, 0x00);//bit[1]:3d_para_en
	fprintf(setting,"\n");
	WriteReg8(0x200014de, 0x01);//dns_cal_en
	fprintf(setting,"\n");
	WriteReg8(0x200014f4, 0x60);//cur_Move_Px_Wt_1x[7:0]
	WriteReg8(0x200014f5, 0x60);
	WriteReg8(0x200014f6, 0x58);
	WriteReg8(0x200014f7, 0x58);
	WriteReg8(0x200014f8, 0x50);
	WriteReg8(0x200014f9, 0x50);
	WriteReg8(0x200014fa, 0x40);
	WriteReg8(0x200014fb, 0x40);
	WriteReg8(0x200014fc, 0x40);//cur_Move_Px_Wt_256x[7:0]
	WriteReg8(0x200014fd, 0x00);//Move_Px_Wt_Cal_EN
	fprintf(setting,"\n");
	WriteReg8(0x200014fe, 0x60);//cur_Still_Px_Wt_1x[7:0]
	WriteReg8(0x200014ff, 0x60);
	WriteReg8(0x20001500, 0x58);
	WriteReg8(0x20001501, 0x58);
	WriteReg8(0x20001502, 0x50);
	WriteReg8(0x20001503, 0x50);
	WriteReg8(0x20001504, 0x40);
	WriteReg8(0x20001505, 0x40);
	WriteReg8(0x20001506, 0x40);//cur_Still_Px_Wt_256x[7:0]
	WriteReg8(0x20001507, 0x00);//Still_Px_Wt_Cal_EN
	fprintf(setting,"\n");
	WriteReg8(0x200014e0, 0x1e);//x0_noise_x_node_1x[7:0]
	WriteReg8(0x200014e1, 0xb4);//x1_noise_x_node_1x[7:0]
	WriteReg8(0x200014e2, 0x1e);
	WriteReg8(0x200014e3, 0xb4);
	WriteReg8(0x200014e4, 0x1e);
	WriteReg8(0x200014e5, 0xb4);
	WriteReg8(0x200014e6, 0x1e);
	WriteReg8(0x200014e7, 0xb4);
	WriteReg8(0x200014e8, 0x1e);
	WriteReg8(0x200014e9, 0xb4);
	WriteReg8(0x200014ea, 0x1e);
	WriteReg8(0x200014eb, 0xb4);
	WriteReg8(0x200014ec, 0x1e);
	WriteReg8(0x200014ed, 0xb4);
	WriteReg8(0x200014ee, 0x1e);
	WriteReg8(0x200014ef, 0xb4);
	WriteReg8(0x200014f0, 0x1e);//x0_noise_x_node_256x[7:0]
	WriteReg8(0x200014f1, 0xb4);//x1_noise_x_node_256x[7:0]
}

///////////////////////////////////////////////////////////////////////////////
//Function : SNR
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  SNR_cfg (void)
{
	WriteReg8(0x200014d4, 0x02);//weight_center
	WriteReg8(0x200014d6, 0x02);
	WriteReg8(0x200014d8, 0x02);
	WriteReg8(0x200014da, 0x02);
	WriteReg8(0x200014dc, 0x02);
	WriteReg8(0x200014d5, 0x38);//scale_sigma_16x
	WriteReg8(0x200014d7, 0x38);
	WriteReg8(0x200014d9, 0x38);
	WriteReg8(0x200014db, 0x38);
	WriteReg8(0x200014dd, 0x38);
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2000, 0x7f);//enable
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2001, 0x01);//inc_shift
	WriteReg8(ISP0_BASE_ADDR+0x2002, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x2003, 0xff);//inc_wave
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2004, 0x10);//slope_k
	WriteReg8(ISP0_BASE_ADDR+0x2005, 0x20);//slope_b
	WriteReg8(ISP0_BASE_ADDR+0x2006, 0x10);//offset_k
	WriteReg8(ISP0_BASE_ADDR+0x2007, 0x20);//offset_b
	WriteReg8(ISP0_BASE_ADDR+0x2008, 0x10);//scale_sigma_p
	WriteReg8(ISP0_BASE_ADDR+0x2009, 0x04);//scale_sigma_b
	WriteReg8(ISP0_BASE_ADDR+0x200a, 0x04);//scale_sigma_d
	WriteReg8(ISP0_BASE_ADDR+0x200b, 0x02);//weight_center
	WriteReg8(ISP0_BASE_ADDR+0x200c, 0x00);//weight_s4
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x200d, 0x18);//scale_sigma_list[0]
	WriteReg8(ISP0_BASE_ADDR+0x200e, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x200f, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x2010, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x2011, 0x38);
	WriteReg8(ISP0_BASE_ADDR+0x2012, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x2013, 0x48);
	WriteReg8(ISP0_BASE_ADDR+0x2014, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x2015, 0x58);//scale_sigma_list[8]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2016, 0x08);//scale_nr_list[0]
	WriteReg8(ISP0_BASE_ADDR+0x2017, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x2018, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x2019, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x201a, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x201b, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x201c, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x201d, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x201e, 0x14);//scale_nr_list[8]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x201f, 0x60);//scale_sigma_actv[0]
	WriteReg8(ISP0_BASE_ADDR+0x2020, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x2021, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x2022, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x2023, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x2024, 0x30);//scale_sigma_actv[5]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2025, 0x00);//scale_sigma_man_en
	WriteReg8(ISP0_BASE_ADDR+0x2026, 0x00);//scale_nr_man_en
	WriteReg8(ISP0_BASE_ADDR+0x2027, 0x40);//scale_sigma_man
	WriteReg8(ISP0_BASE_ADDR+0x2028, 0x40);//scale_nr_man
}

///////////////////////////////////////////////////////////////////////////////
//Function : YNR
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  YNR_cfg (void)
{
	fprintf(setting,"//YNR\n");
	WriteReg8(ISP0_BASE_ADDR+0x4a00, 0x03);//enable
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4a01, 0x08);//slope_k
	WriteReg8(ISP0_BASE_ADDR+0x4a02, 0x08);//slope_b
	WriteReg8(ISP0_BASE_ADDR+0x4a03, 0x08);//offset_k
	WriteReg8(ISP0_BASE_ADDR+0x4a04, 0x08);//offset_b
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4a05, 0x01);//scale_ynr0
	WriteReg8(ISP0_BASE_ADDR+0x4a06, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x4a07, 0x06);
	WriteReg8(ISP0_BASE_ADDR+0x4a08, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x4a09, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x4a0a, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x4a0b, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x4a0c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x4a0d, 0x28);//scale_ynr8
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4a0e, 0x30);//scale_enh0
	WriteReg8(ISP0_BASE_ADDR+0x4a0f, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x4a10, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x4a11, 0x1a);
	WriteReg8(ISP0_BASE_ADDR+0x4a12, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x4a13, 0x16);
	WriteReg8(ISP0_BASE_ADDR+0x4a14, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x4a15, 0x12);
	WriteReg8(ISP0_BASE_ADDR+0x4a16, 0x10);//scale_enh8
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4a17, 0x10);//scale_ynr_man
	WriteReg8(ISP0_BASE_ADDR+0x4a18, 0x10);//scale_enh_man
	fprintf(setting,"\n");
	fprintf(setting,"//CNR\n");
	WriteReg8(ISP0_BASE_ADDR+0x4c00, 0x05);//bit[2]:cnr_en;bit[1]:scale_cnr_man_en;bit[0]:green_keep_en
	WriteReg8(ISP0_BASE_ADDR+0x4c01, 0x20);//edge_th_dn
	WriteReg8(ISP0_BASE_ADDR+0x4c02, 0x60);//edge_th_up
	WriteReg8(ISP0_BASE_ADDR+0x4c03, 0x10);//weight_hm_up
	WriteReg8(ISP0_BASE_ADDR+0x4c04, 0x04);//weight_hm_dn
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4c06, 0x04);//scale_cnr_list0
	WriteReg8(ISP0_BASE_ADDR+0x4c07, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x4c08, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x4c09, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x4c0a, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x4c0b, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x4c0c, 0x38);
	WriteReg8(ISP0_BASE_ADDR+0x4c0d, 0x3c);
	WriteReg8(ISP0_BASE_ADDR+0x4c0e, 0x40);//scale_cnr_list8
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4c0f, 0x40);//green_u_up
	WriteReg8(ISP0_BASE_ADDR+0x4c10, 0x40);//green_v_up
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4c11, 0x20);//scale_cnr_man
}

///////////////////////////////////////////////////////////////////////////////
//Function : CIP
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  CIP_cfg (void)
{
	fprintf(setting,"//cip22\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f00, 0x01);//fnr_en
	WriteReg8(ISP0_BASE_ADDR+0x0f01, 0x01);//enh_en
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f02, 0x0c);//slope_k
	WriteReg8(ISP0_BASE_ADDR+0x0f03, 0x18);//slope_b
	WriteReg8(ISP0_BASE_ADDR+0x0f04, 0x0c);//offset_k
	WriteReg8(ISP0_BASE_ADDR+0x0f05, 0x18);//offset_b
	WriteReg8(ISP0_BASE_ADDR+0x0f06, 0x18);//fnr_str
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f07, 0x02);//scale_sig_list[0]
	WriteReg8(ISP0_BASE_ADDR+0x0f08, 0x04);
	WriteReg8(ISP0_BASE_ADDR+0x0f09, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x0f0a, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x0f0b, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x0f0c, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x0f0d, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x0f0e, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x0f0f, 0x38);//scale_sig_list[8]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f10, 0x1e);//scale_enh_list[0]
	WriteReg8(ISP0_BASE_ADDR+0x0f11, 0x1c);
	WriteReg8(ISP0_BASE_ADDR+0x0f12, 0x1a);
	WriteReg8(ISP0_BASE_ADDR+0x0f13, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x0f14, 0x16);
	WriteReg8(ISP0_BASE_ADDR+0x0f15, 0x14);
	WriteReg8(ISP0_BASE_ADDR+0x0f16, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x0f17, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x0f18, 0x08);//scale_enh_list[0][8]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f19, 0x00);//scale_sbl_list[0]
	WriteReg8(ISP0_BASE_ADDR+0x0f1a, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x0f1b, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x0f1c, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x0f1d, 0x38);
	WriteReg8(ISP0_BASE_ADDR+0x0f1e, 0x48);//scale_sbl_list[5]
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x0f1f, 0x00);//scale_sig_man_en
	WriteReg8(ISP0_BASE_ADDR+0x0f20, 0x00);//scale_enh_man_en
	WriteReg8(ISP0_BASE_ADDR+0x0f21, 0x20);//scale_sig_man
	WriteReg8(ISP0_BASE_ADDR+0x0f22, 0x40);//scale_enh_man
	
	fprintf(setting,"\n");
	fprintf(setting,"//cip10\n");
	WriteReg8(ISP0_BASE_ADDR+0x5000, 0x00);//bit[7:4]:noise_y bit[3:0]:lsharp
	
	WriteReg8(ISP0_BASE_ADDR+0x5002, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5003, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5004, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5005, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5006, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5007, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5008, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x5009, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x500a, 0x05);//min_shp
	WriteReg8(ISP0_BASE_ADDR+0x500b, 0x10);//max_shp
	WriteReg8(ISP0_BASE_ADDR+0x500c, 0x05);//min_detail
	WriteReg8(ISP0_BASE_ADDR+0x500d, 0x12);//max_detail
	WriteReg8(ISP0_BASE_ADDR+0x500e, 0x01);//min_shp_gain
	WriteReg8(ISP0_BASE_ADDR+0x500f, 0x3f);//max_shp_gain
	WriteReg8(ISP0_BASE_ADDR+0x5010, 0x60);
}


///////////////////////////////////////////////////////////////////////////////
//Function : YDE
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  YDE_cfg (void)
{
	WriteReg8(ISP0_BASE_ADDR+0x4b00, 0x12);//bit[4]:hfreq_hth_en;bit[3]:scale_all_man_en;bit[2]:scale_sig_man_en;bit[1]:yde_en
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b01, 0x04);//slope_k
	WriteReg8(ISP0_BASE_ADDR+0x4b02, 0x04);//slope_b
	WriteReg8(ISP0_BASE_ADDR+0x4b03, 0x02);//offset_k
	WriteReg8(ISP0_BASE_ADDR+0x4b04, 0x02);//offset_b
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b05, 0x06);//scale_sig0
	WriteReg8(ISP0_BASE_ADDR+0x4b06, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x4b07, 0x0a);
	WriteReg8(ISP0_BASE_ADDR+0x4b08, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x4b09, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x4b0a, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x4b0b, 0x24);
	WriteReg8(ISP0_BASE_ADDR+0x4b0c, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x4b0d, 0x2c);//scale_sig8
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b0e, 0xf0);//scale_all0
	WriteReg8(ISP0_BASE_ADDR+0x4b0f, 0xe0);
	WriteReg8(ISP0_BASE_ADDR+0x4b10, 0xd0);
	WriteReg8(ISP0_BASE_ADDR+0x4b11, 0xc0);
	WriteReg8(ISP0_BASE_ADDR+0x4b12, 0xb8);
	WriteReg8(ISP0_BASE_ADDR+0x4b13, 0xb0);
	WriteReg8(ISP0_BASE_ADDR+0x4b14, 0xa8);
	WriteReg8(ISP0_BASE_ADDR+0x4b15, 0xa0);
	WriteReg8(ISP0_BASE_ADDR+0x4b16, 0x98);//scale_all8
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b17, 0x20);//scale_enh_actv0
	WriteReg8(ISP0_BASE_ADDR+0x4b18, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x4b19, 0x40);
	WriteReg8(ISP0_BASE_ADDR+0x4b1a, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x4b1b, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x4b1c, 0x70);//scale_enh_actv5
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b1f, 0x20);//scale_pos
	WriteReg8(ISP0_BASE_ADDR+0x4b20, 0x60);//scale_neg
	WriteReg8(ISP0_BASE_ADDR+0x4b21, 0x08);//sth_var_ratio
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b22, 0x00);//x_node0
	WriteReg8(ISP0_BASE_ADDR+0x4b23, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x4b24, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x4b25, 0xb0);
	WriteReg8(ISP0_BASE_ADDR+0x4b26, 0xa0);
	WriteReg8(ISP0_BASE_ADDR+0x4b27, 0xf0);
	WriteReg8(ISP0_BASE_ADDR+0x4b28, 0xa0);//y_node2
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b29, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x4b2a, 0x55);//y_slope0
	WriteReg8(ISP0_BASE_ADDR+0x4b2b, 0x01);
	WriteReg8(ISP0_BASE_ADDR+0x4b2c, 0xaa);//y_slope1
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4b1d, 0x41);//scale_sig_man
	WriteReg8(ISP0_BASE_ADDR+0x4b1e, 0x81);//scale_all_man

}


///////////////////////////////////////////////////////////////////////////////
//Function : CADJ
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  CADJ_cfg (void)
{
	WriteReg8(ISP0_BASE_ADDR+0x4300, 0x00);//bit[0]:uv_mode
	WriteReg8(ISP0_BASE_ADDR+0x4301, 0x14);//color_enhance_en
	WriteReg8(ISP0_BASE_ADDR+0x4302, 0x0c);//chroma_suppress_en
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4303, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4304, 0x20);//Kr [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x4305, 0x14);//yr1
	WriteReg8(ISP0_BASE_ADDR+0x4306, 0x28);//yr2
	WriteReg8(ISP0_BASE_ADDR+0x4307, 0xc8);//yr3
	WriteReg8(ISP0_BASE_ADDR+0x4308, 0xeb);//yr4
	WriteReg8(ISP0_BASE_ADDR+0x4309, 0x66);//yrm1
	WriteReg8(ISP0_BASE_ADDR+0x430a, 0x75);//yrm3
	WriteReg8(ISP0_BASE_ADDR+0x430b, 0x06);//yrs1
	WriteReg8(ISP0_BASE_ADDR+0x430c, 0x07);//yrs3
	WriteReg8(ISP0_BASE_ADDR+0x430d, 0x7f);//cb_rzone
	WriteReg8(ISP0_BASE_ADDR+0x430e, 0xc8);//cr_rzone
	WriteReg8(ISP0_BASE_ADDR+0x430f, 0x18);//transwidth_r
	WriteReg8(ISP0_BASE_ADDR+0x4310, 0x15);//transslope_r
	WriteReg8(ISP0_BASE_ADDR+0x4311, 0x09);//transtrunc_r
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4312, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4313, 0xc0);//Kg [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x4314, 0x00);//yg1
	WriteReg8(ISP0_BASE_ADDR+0x4315, 0x20);//yg2
	WriteReg8(ISP0_BASE_ADDR+0x4316, 0x80);//yg3
	WriteReg8(ISP0_BASE_ADDR+0x4317, 0xa0);//yg4
	WriteReg8(ISP0_BASE_ADDR+0x4318, 0x60);//ygm1
	WriteReg8(ISP0_BASE_ADDR+0x4319, 0x60);//ygm3
	WriteReg8(ISP0_BASE_ADDR+0x431a, 0x04);//ygs1
	WriteReg8(ISP0_BASE_ADDR+0x431b, 0x04);//ygs3
	WriteReg8(ISP0_BASE_ADDR+0x431c, 0x26);//cb_gzone
	WriteReg8(ISP0_BASE_ADDR+0x431d, 0xee);//cr_gzone
	WriteReg8(ISP0_BASE_ADDR+0x431e, 0x18);//transwidth_g
	WriteReg8(ISP0_BASE_ADDR+0x431f, 0x15);//transslope_g
	WriteReg8(ISP0_BASE_ADDR+0x4320, 0x09);//transtrunc_g
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4321, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4322, 0x20);//Kb [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x4323, 0x50);//yb1
	WriteReg8(ISP0_BASE_ADDR+0x4324, 0x96);//yb2
	WriteReg8(ISP0_BASE_ADDR+0x4325, 0xeb);//yb3
	WriteReg8(ISP0_BASE_ADDR+0x4326, 0xff);//yb4
	WriteReg8(ISP0_BASE_ADDR+0x4327, 0x75);//ybm1
	WriteReg8(ISP0_BASE_ADDR+0x4328, 0x66);//ybm3
	WriteReg8(ISP0_BASE_ADDR+0x4329, 0x08);//ybs1
	WriteReg8(ISP0_BASE_ADDR+0x432a, 0x06);//ybs3
	WriteReg8(ISP0_BASE_ADDR+0x432b, 0xdc);//cb_bzone
	WriteReg8(ISP0_BASE_ADDR+0x432c, 0xec);//cr_bzone
	WriteReg8(ISP0_BASE_ADDR+0x432d, 0x18);//transwidth_b
	WriteReg8(ISP0_BASE_ADDR+0x432e, 0x15);//transslope_b
	WriteReg8(ISP0_BASE_ADDR+0x432f, 0x09);//transtrunc_b
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4330, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4331, 0x20);//Kp  [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x4332, 0x50);//yp1
	WriteReg8(ISP0_BASE_ADDR+0x4333, 0x96);//yp2
	WriteReg8(ISP0_BASE_ADDR+0x4334, 0xeb);//yp3
	WriteReg8(ISP0_BASE_ADDR+0x4335, 0xff);//yp4
	WriteReg8(ISP0_BASE_ADDR+0x4336, 0x75);//ypm1
	WriteReg8(ISP0_BASE_ADDR+0x4337, 0x66);//ypm3
	WriteReg8(ISP0_BASE_ADDR+0x4338, 0x08);//yps1
	WriteReg8(ISP0_BASE_ADDR+0x4339, 0x06);//yps3
	WriteReg8(ISP0_BASE_ADDR+0x433a, 0x40);//cb_pzone
	WriteReg8(ISP0_BASE_ADDR+0x433b, 0x40);//cr_pzone
	WriteReg8(ISP0_BASE_ADDR+0x433c, 0x18);//transwidth_p
	WriteReg8(ISP0_BASE_ADDR+0x433d, 0x15);//transslope_p
	WriteReg8(ISP0_BASE_ADDR+0x433e, 0x09);//transtrunc_p
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x433F, 0x00);//y1
	WriteReg8(ISP0_BASE_ADDR+0x4340, 0x18);//y2
	WriteReg8(ISP0_BASE_ADDR+0x4341, 0xa8);//y3
	WriteReg8(ISP0_BASE_ADDR+0x4342, 0xb8);//y4
	WriteReg8(ISP0_BASE_ADDR+0x4343, 0x55);//ym1
	WriteReg8(ISP0_BASE_ADDR+0x4344, 0x40);//ym3
	WriteReg8(ISP0_BASE_ADDR+0x4345, 0x04);//ys1
	WriteReg8(ISP0_BASE_ADDR+0x4346, 0x03);//ys3
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4347, 0xc8);//c1
	WriteReg8(ISP0_BASE_ADDR+0x4348, 0xf0);//c2
	WriteReg8(ISP0_BASE_ADDR+0x4349, 0x66);//cm1
	WriteReg8(ISP0_BASE_ADDR+0x434a, 0x05);//cs1
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x434b, 0x00);//d_l
	WriteReg8(ISP0_BASE_ADDR+0x434c, 0x00);//d_s
	WriteReg8(ISP0_BASE_ADDR+0x434d, 0x00);//d_r
	WriteReg8(ISP0_BASE_ADDR+0x434e, 0x07);//qk
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x434f, 0x60);//scale_enhance_1x
	WriteReg8(ISP0_BASE_ADDR+0x4350, 0x5e);
	WriteReg8(ISP0_BASE_ADDR+0x4351, 0x5c);
	WriteReg8(ISP0_BASE_ADDR+0x4352, 0x58);
	WriteReg8(ISP0_BASE_ADDR+0x4353, 0x54);
	WriteReg8(ISP0_BASE_ADDR+0x4354, 0x50);
	WriteReg8(ISP0_BASE_ADDR+0x4355, 0x4c);
	WriteReg8(ISP0_BASE_ADDR+0x4356, 0x48);
	WriteReg8(ISP0_BASE_ADDR+0x4357, 0x44);//scale_enhance_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4358, 0x04);//scale_suppress_1x
	WriteReg8(ISP0_BASE_ADDR+0x4359, 0x08);
	WriteReg8(ISP0_BASE_ADDR+0x435a, 0x0c);
	WriteReg8(ISP0_BASE_ADDR+0x435b, 0x10);
	WriteReg8(ISP0_BASE_ADDR+0x435c, 0x18);
	WriteReg8(ISP0_BASE_ADDR+0x435d, 0x20);
	WriteReg8(ISP0_BASE_ADDR+0x435e, 0x28);
	WriteReg8(ISP0_BASE_ADDR+0x435f, 0x30);
	WriteReg8(ISP0_BASE_ADDR+0x4360, 0x38);//scale_suppress_256x
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x4361, 0x00);//scale_enhance_man_en
	WriteReg8(ISP0_BASE_ADDR+0x4362, 0x80);//scale_enhance_man
	WriteReg8(ISP0_BASE_ADDR+0x4363, 0x00);//scale_suppress_man_en
	WriteReg8(ISP0_BASE_ADDR+0x4364, 0x80);//scale_suppress_man
	WriteReg8(ISP0_BASE_ADDR+0x4365, 0x00);//color_enhance_max_man_en
	WriteReg8(ISP0_BASE_ADDR+0x4366, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4367, 0x20);//color_enhance_max_man_r [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x4368, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x4369, 0xc0);//color_enhance_max_man_g [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x436a, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x436b, 0x60);//color_enhance_max_man_b [8:0]
	WriteReg8(ISP0_BASE_ADDR+0x436c, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x436d, 0x20);//color_enhance_max_man_p [8:0]
}

///////////////////////////////////////////////////////////////////////////////
//Function : IQ_oneself
//Author   : nathan
//Notes    : need to configure according to isp_size_in
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  IQ_oneself_cfg (unsigned char hdr_mode,
                     unsigned char mjpeg_enable,
                     unsigned short hsize_in,
                     unsigned short vsize_in,
                     unsigned short max_expo_line,
                     unsigned short banding_mode,
                     unsigned short flicker60HzUnit,
                     unsigned short flicker50HzUnit,
                     int long2short_delay,
                     int short2vs_delay,
                     int afc_enable
)
{
	fprintf(setting,"//AE_base1\n");
	WriteReg8(0x200000c2, 0x20);//min_exp[7:0]
	WriteReg8(0x200000c3, 0x00);//min_exp[15:8]
	
	WriteReg8(0x200000c4, (max_expo_line<<4)&0xff);//max_exp[7:0]
	WriteReg8(0x200000c5, ((max_expo_line<<4)>>8)&0xff);//max_exp[15:8]
	WriteReg8(0x200000c6, ((max_expo_line<<4)>>16)&0xff);//max_exp[23:16]
	WriteReg8(0x200000c7, ((max_expo_line<<4)>>24)&0xff);//max_exp[31:24]

	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		WriteReg8(0x2000024e, 0x10);//min_exp_s[7:0]
		WriteReg8(0x2000024f, 0x00);//min_exp_s[15:8]
		
		WriteReg8(0x20000254, (long2short_delay<<4)&0xff);//max_exp_s[7:0]
		WriteReg8(0x20000255, ((long2short_delay<<4)>>8)&0xff);//max_exp_s[15:8]
		WriteReg8(0x20000256, ((long2short_delay<<4)>>16)&0xff);//max_exp_s[23:16]
		WriteReg8(0x20000257, ((long2short_delay<<4)>>24)&0xff);//max_exp_s[31:24]
	}

	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		WriteReg8(0x2000025c, 0x10);//min_exp_VS
		WriteReg8(0x2000025d, 0x00);
		
		WriteReg8(0x20000260, (short2vs_delay<<4)&0xff);//max_exp_VS
		WriteReg8(0x20000261, ((short2vs_delay<<4)>>8)&0xff);
		WriteReg8(0x20000262, ((short2vs_delay<<4)>>16)&0xff);
		WriteReg8(0x20000263, ((short2vs_delay<<4)>>24)&0xff);
	}
	fprintf(setting,"\n");
	WriteReg8(0x200000f4, banding_mode);//flicker0x00:disable0x01:60Hz0x02:50Hz
	WriteReg8(0x200000f5, 0x01);
	WriteReg8(0x200000f6, flicker60HzUnit &0xf0);//60Hz
	WriteReg8(0x200000f7, (flicker60HzUnit>>8) &0xff);
	WriteReg8(0x200000f8, flicker50HzUnit &0xf0);//50Hz
	WriteReg8(0x200000f9, (flicker50HzUnit>>8) &0xff);
	
	fprintf(setting,"\n");
	fprintf(setting,"//AE_window\n");
	WriteReg8(ISP0_BASE_ADDR+0x1f00, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1f01, 0x00);//win_Xstart
	WriteReg8(ISP0_BASE_ADDR+0x1f02, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1f03, 0x00);//win_Ystart
	WriteReg8(ISP0_BASE_ADDR+0x1f04, (hsize_in>>8)&0xff);
	WriteReg8(ISP0_BASE_ADDR+0x1f05, hsize_in&0xff);//win_width
	WriteReg8(ISP0_BASE_ADDR+0x1f06, (vsize_in>>8)&0xff);
	WriteReg8(ISP0_BASE_ADDR+0x1f07, (vsize_in-0x10)&0xff);//win_height
	WriteReg8(ISP0_BASE_ADDR+0x1f08, 0x03);
	
	fprintf(setting,"\n");
	fprintf(setting,"//Lenc_ratio\n");
	WriteReg8(ISP0_BASE_ADDR+0x000e, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x000f, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0010, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0011, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x0012, 0x80);//lenc_skip
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x03ca, 0x03);//lenc_ratio_long
	WriteReg8(ISP0_BASE_ADDR+0x03cb, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x03cc, 0x05);
	WriteReg8(ISP0_BASE_ADDR+0x03cd, 0xb0);
	WriteReg8(ISP0_BASE_ADDR+0x03ce, 0x03);
	WriteReg8(ISP0_BASE_ADDR+0x03cf, 0x33);
	WriteReg8(ISP0_BASE_ADDR+0x03d0, 0x02);
	WriteReg8(ISP0_BASE_ADDR+0x03d1, 0xd8);

	if (hdr_mode !=0) {
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x02ca, 0x03);//lenc_ratio_short
		WriteReg8(ISP0_BASE_ADDR+0x02cb, 0x33);
		WriteReg8(ISP0_BASE_ADDR+0x02cc, 0x05);
		WriteReg8(ISP0_BASE_ADDR+0x02cd, 0xb0);
		WriteReg8(ISP0_BASE_ADDR+0x02ce, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x02cf, 0x33);
		WriteReg8(ISP0_BASE_ADDR+0x02d0, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x02d1, 0xd8);
	}

	if (hdr_mode ==3) {
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x04ca, 0x04);//lenc_ratio_veryshort
		WriteReg8(ISP0_BASE_ADDR+0x04cb, 0xcc);
		WriteReg8(ISP0_BASE_ADDR+0x04cc, 0x08);
		WriteReg8(ISP0_BASE_ADDR+0x04cd, 0x88);
		WriteReg8(ISP0_BASE_ADDR+0x04ce, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x04cf, 0xcc);
		WriteReg8(ISP0_BASE_ADDR+0x04d0, 0x04);
		WriteReg8(ISP0_BASE_ADDR+0x04d1, 0x44);
	}

	if (afc_enable ==1) {
		fprintf(setting,"\n");
		fprintf(setting,"//AF_size\n");
		WriteReg8(ISP0_BASE_ADDR+0x1e00, 0x90);
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x1e01, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x1e02, 0xf0);
		WriteReg8(ISP0_BASE_ADDR+0x1e03, 0x03);
		WriteReg8(ISP0_BASE_ADDR+0x1e04, 0xf0);
		fprintf(setting,"\n");
		WriteReg8(ISP0_BASE_ADDR+0x1e0f, 0x06);
		WriteReg8(ISP0_BASE_ADDR+0x1e10, 0x28);
		WriteReg8(ISP0_BASE_ADDR+0x1e11, 0x02);
		WriteReg8(ISP0_BASE_ADDR+0x1e12, 0x9a);
		
		//WriteReg8(ISP0_BASE_ADDR+0x1e0a, 0x00);
		//WriteReg8(ISP0_BASE_ADDR+0x1e0b, 0x10);
		//WriteReg8(ISP0_BASE_ADDR+0x1e0c, 0xff);
		
		//WriteReg8(ISP0_BASE_ADDR+0x1e21, 0xff);
	}
	
	if (mjpeg_enable ==1) {
		fprintf(setting,"\n");
		fprintf(setting,"//jpeg_qs\n");
  	WriteReg8(0x80280180, 0x20);
  	WriteReg8(0x80280182, 0x0f);//jpeg_qs_l
  	WriteReg8(0x80280183, 0x0f);//jpeg_qs_h
  	WriteReg8(0x802801a8, 0x0e);
  	WriteReg8(0x802801a9, 0x6d);
	}
}


///////////////////////////////////////////////////////////////////////////////
//Function : isp_osd_sde
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  isp_osd_sde_cfg (unsigned char hdr_mode)
{
	fprintf(setting,"//isp_osd\n");
	WriteReg8(ISP0_BASE_ADDR+0x2300, 0x2a);//bit[7:4]:osd1_debug_data_sel
	WriteReg8(ISP0_BASE_ADDR+0x2301, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2302, 0x30);//osd1_win_Hstart
	WriteReg8(ISP0_BASE_ADDR+0x2303, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2304, 0x10);//osd1_win_Vstart
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2340, 0x0a);//bit[7:4]:osd2_debug_data_sel
	WriteReg8(ISP0_BASE_ADDR+0x2341, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2342, 0x30);//osd2_win_Hstart
	WriteReg8(ISP0_BASE_ADDR+0x2343, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2344, 0x30);//osd2_win_Vstart
	fprintf(setting,"\n");
	WriteReg8(ISP0_BASE_ADDR+0x2380, 0x0a);//bit[7:4]:osd3_debug_data_sel
	WriteReg8(ISP0_BASE_ADDR+0x2381, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2382, 0x30);//osd3_win_Hstart
	WriteReg8(ISP0_BASE_ADDR+0x2383, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x2384, 0x50);//osd3_win_Vstart
	
	fprintf(setting,"\n");
	fprintf(setting,"//sde\n");
	WriteReg8(ISP0_BASE_ADDR+0x1700, 0x0d);
	WriteReg8(ISP0_BASE_ADDR+0x1701, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x1702, 0x60);
	WriteReg8(ISP0_BASE_ADDR+0x1703, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x1704, 0x20);//contrast_ygain
	WriteReg8(ISP0_BASE_ADDR+0x1705, 0x80);
	WriteReg8(ISP0_BASE_ADDR+0x1706, 0x00);
	WriteReg8(ISP0_BASE_ADDR+0x1707, 0x00);//ybright

}

///////////////////////////////////////////////////////////////////////////////
//Function : IQ_switch
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void  IQ_switch_cfg (unsigned char hdr_mode, unsigned short hsize_in, unsigned short vsize_in,
										 unsigned short snr_blc_mode, unsigned short snr_blc_page_addr,	unsigned short snr_blc_page_value,
										 unsigned short snr_blc_addr[4], unsigned short snr_blc_channel_num)
{
	fprintf(setting,"//scene_condition\n");
	WriteReg8(0x20000d38, 0xb0);
	WriteReg8(0x20000d39, 0x00);//area_avg_switch_h
	WriteReg8(0x20000d3a, 0x00);
	WriteReg8(0x20000d3b, 0x02);//area_avg_switch_l
	WriteReg8(0x20000d3c, 0x80);
	WriteReg8(0x20000d3d, 0x00);//avg_switch
	WriteReg8(0x20000d3e, 0x60);
	WriteReg8(0x20000d3f, 0x00);//gain_swtch_0
	WriteReg8(0x20000d40, 0xa0);
	WriteReg8(0x20000d41, 0x00);//gain_swtch_1
	WriteReg8(0x20000d42, 0x00);
	WriteReg8(0x20000d43, 0x06);//gain_swtch_2
	WriteReg8(0x20000d44, 0x00);
	WriteReg8(0x20000d45, 0x09);//gain_swtch_3
	
	fprintf(setting,"\n");
	fprintf(setting,"//avg_size\n");
	WriteReg8(0x20000c60, 0x00);//day_mode
	WriteReg8(0x20000c61, 0x00);
	WriteReg8(0x20000c62, 0x00);
	WriteReg8(0x20000c63, 0x00);
	WriteReg8(0x20000c64, (hsize_in>>8)&0xff));
	WriteReg8(0x20000c65, hsize_in&0xff);
	WriteReg8(0x20000c66, (vsize_in>>8)&0xff));
	WriteReg8(0x20000c67, (vsize_in-0x10)&0xff);
	fprintf(setting,"\n");
	WriteReg8(0x20000c68, 0x00);//night_mode
	WriteReg8(0x20000c69, 0x00);
	WriteReg8(0x20000c6a, 0x00);
	WriteReg8(0x20000c6b, 0x00);
	WriteReg8(0x20000c6c, (hsize_in>>8)&0xff)));
	WriteReg8(0x20000c6d, hsize_in&0xff);
	WriteReg8(0x20000c6e, (vsize_in>>8)&0xff));
	WriteReg8(0x20000c6f, (vsize_in-0x10)&0xff);
	fprintf(setting,"\n");
	WriteReg8(0x20000c70, 0x00);//midnight_mode
	WriteReg8(0x20000c71, 0x00);
	WriteReg8(0x20000c72, 0x00);
	WriteReg8(0x20000c73, 0x00);
	WriteReg8(0x20000c74, (hsize_in>>8)&0xff)));
	WriteReg8(0x20000c75, hsize_in&0xff);
	WriteReg8(0x20000c76, (vsize_in>>8)&0xff));
	WriteReg8(0x20000c77, (vsize_in-0x10)&0xff);
	
	fprintf(setting,"\n");
	fprintf(setting,"//avg_weight\n");
	WriteReg8(0x20000c78, 0x82);//day_mode
	WriteReg8(0x20000c79, 0x82);
	WriteReg8(0x20000c7a, 0x82);
	WriteReg8(0x20000c7b, 0x82);
	WriteReg8(0x20000c7c, 0x82);
	WriteReg8(0x20000c7d, 0x82);
	WriteReg8(0x20000c7e, 0x82);
	WriteReg8(0x20000c7f, 0x82);
	fprintf(setting,"\n");
	WriteReg8(0x20000c80, 0x02);
	WriteReg8(0x20000c81, 0x02);
	WriteReg8(0x20000c82, 0x02);
	WriteReg8(0x20000c83, 0x04);
	WriteReg8(0x20000c84, 0x04);
	WriteReg8(0x20000c85, 0x02);
	WriteReg8(0x20000c86, 0x02);
	WriteReg8(0x20000c87, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000c88, 0x04);
	WriteReg8(0x20000c89, 0x04);
	WriteReg8(0x20000c8a, 0x04);
	WriteReg8(0x20000c8b, 0x06);
	WriteReg8(0x20000c8c, 0x06);
	WriteReg8(0x20000c8d, 0x04);
	WriteReg8(0x20000c8e, 0x04);
	WriteReg8(0x20000c8f, 0x04);
	fprintf(setting,"\n");
	WriteReg8(0x20000c90, 0x06);
	WriteReg8(0x20000c91, 0x06);
	WriteReg8(0x20000c92, 0x06);
	WriteReg8(0x20000c93, 0x0c);
	WriteReg8(0x20000c94, 0x0c);
	WriteReg8(0x20000c95, 0x06);
	WriteReg8(0x20000c96, 0x06);
	WriteReg8(0x20000c97, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000c98, 0x06);
	WriteReg8(0x20000c99, 0x06);
	WriteReg8(0x20000c9a, 0x06);
	WriteReg8(0x20000c9b, 0x0f);
	WriteReg8(0x20000c9c, 0x0f);
	WriteReg8(0x20000c9d, 0x06);
	WriteReg8(0x20000c9e, 0x06);
	WriteReg8(0x20000c9f, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000ca0, 0x06);
	WriteReg8(0x20000ca1, 0x06);
	WriteReg8(0x20000ca2, 0x06);
	WriteReg8(0x20000ca3, 0x0c);
	WriteReg8(0x20000ca4, 0x0c);
	WriteReg8(0x20000ca5, 0x06);
	WriteReg8(0x20000ca6, 0x06);
	WriteReg8(0x20000ca7, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000ca8, 0x04);
	WriteReg8(0x20000ca9, 0x04);
	WriteReg8(0x20000caa, 0x04);
	WriteReg8(0x20000cab, 0x06);
	WriteReg8(0x20000cac, 0x06);
	WriteReg8(0x20000cad, 0x04);
	WriteReg8(0x20000cae, 0x04);
	WriteReg8(0x20000caf, 0x04);
	fprintf(setting,"\n");
	WriteReg8(0x20000cb0, 0x02);
	WriteReg8(0x20000cb1, 0x02);
	WriteReg8(0x20000cb2, 0x02);
	WriteReg8(0x20000cb3, 0x04);
	WriteReg8(0x20000cb4, 0x04);
	WriteReg8(0x20000cb5, 0x02);
	WriteReg8(0x20000cb6, 0x02);
	WriteReg8(0x20000cb7, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000cb8, 0x81);//night_mode
	WriteReg8(0x20000cb9, 0x81);
	WriteReg8(0x20000cba, 0x81);
	WriteReg8(0x20000cbb, 0x81);
	WriteReg8(0x20000cbc, 0x81);
	WriteReg8(0x20000cbd, 0x81);
	WriteReg8(0x20000cbe, 0x81);
	WriteReg8(0x20000cbf, 0x81);
	fprintf(setting,"\n");
	WriteReg8(0x20000cc0, 0x01);
	WriteReg8(0x20000cc1, 0x01);
	WriteReg8(0x20000cc2, 0x01);
	WriteReg8(0x20000cc3, 0x04);
	WriteReg8(0x20000cc4, 0x04);
	WriteReg8(0x20000cc5, 0x01);
	WriteReg8(0x20000cc6, 0x01);
	WriteReg8(0x20000cc7, 0x01);
	fprintf(setting,"\n");
	WriteReg8(0x20000cc8, 0x02);
	WriteReg8(0x20000cc9, 0x02);
	WriteReg8(0x20000cca, 0x02);
	WriteReg8(0x20000ccb, 0x08);
	WriteReg8(0x20000ccc, 0x08);
	WriteReg8(0x20000ccd, 0x02);
	WriteReg8(0x20000cce, 0x02);
	WriteReg8(0x20000ccf, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000cd0, 0x02);
	WriteReg8(0x20000cd1, 0x02);
	WriteReg8(0x20000cd2, 0x02);
	WriteReg8(0x20000cd3, 0x0c);
	WriteReg8(0x20000cd4, 0x0c);
	WriteReg8(0x20000cd5, 0x02);
	WriteReg8(0x20000cd6, 0x02);
	WriteReg8(0x20000cd7, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000cd8, 0x02);
	WriteReg8(0x20000cd9, 0x02);
	WriteReg8(0x20000cda, 0x02);
	WriteReg8(0x20000cdb, 0x0f);
	WriteReg8(0x20000cdc, 0x0f);
	WriteReg8(0x20000cdd, 0x02);
	WriteReg8(0x20000cde, 0x02);
	WriteReg8(0x20000cdf, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000ce0, 0x02);
	WriteReg8(0x20000ce1, 0x02);
	WriteReg8(0x20000ce2, 0x02);
	WriteReg8(0x20000ce3, 0x0c);
	WriteReg8(0x20000ce4, 0x0c);
	WriteReg8(0x20000ce5, 0x02);
	WriteReg8(0x20000ce6, 0x02);
	WriteReg8(0x20000ce7, 0x02);
	fprintf(setting,"\n");
	WriteReg8(0x20000ce8, 0x01);
	WriteReg8(0x20000ce9, 0x01);
	WriteReg8(0x20000cea, 0x01);
	WriteReg8(0x20000ceb, 0x08);
	WriteReg8(0x20000cec, 0x08);
	WriteReg8(0x20000ced, 0x01);
	WriteReg8(0x20000cee, 0x01);
	WriteReg8(0x20000cef, 0x01);
	fprintf(setting,"\n");
	WriteReg8(0x20000cf0, 0x01);
	WriteReg8(0x20000cf1, 0x01);
	WriteReg8(0x20000cf2, 0x01);
	WriteReg8(0x20000cf3, 0x04);
	WriteReg8(0x20000cf4, 0x04);
	WriteReg8(0x20000cf5, 0x01);
	WriteReg8(0x20000cf6, 0x01);
	WriteReg8(0x20000cf7, 0x01);
	fprintf(setting,"\n");
	WriteReg8(0x20000cf8, 0x86);//mid_night
	WriteReg8(0x20000cf9, 0x86);
	WriteReg8(0x20000cfa, 0x86);
	WriteReg8(0x20000cfb, 0x88);
	WriteReg8(0x20000cfc, 0x88);
	WriteReg8(0x20000cfd, 0x86);
	WriteReg8(0x20000cfe, 0x86);
	WriteReg8(0x20000cff, 0x86);
	fprintf(setting,"\n");
	WriteReg8(0x20000d00, 0x06);
	WriteReg8(0x20000d01, 0x06);
	WriteReg8(0x20000d02, 0x06);
	WriteReg8(0x20000d03, 0x08);
	WriteReg8(0x20000d04, 0x08);
	WriteReg8(0x20000d05, 0x06);
	WriteReg8(0x20000d06, 0x06);
	WriteReg8(0x20000d07, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000d08, 0x06);
	WriteReg8(0x20000d09, 0x06);
	WriteReg8(0x20000d0a, 0x06);
	WriteReg8(0x20000d0b, 0x0a);
	WriteReg8(0x20000d0c, 0x0a);
	WriteReg8(0x20000d0d, 0x06);
	WriteReg8(0x20000d0e, 0x06);
	WriteReg8(0x20000d0f, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000d10, 0x08);
	WriteReg8(0x20000d11, 0x08);
	WriteReg8(0x20000d12, 0x08);
	WriteReg8(0x20000d13, 0x0c);
	WriteReg8(0x20000d14, 0x0c);
	WriteReg8(0x20000d15, 0x08);
	WriteReg8(0x20000d16, 0x08);
	WriteReg8(0x20000d17, 0x08);
	fprintf(setting,"\n");
	WriteReg8(0x20000d18, 0x08);
	WriteReg8(0x20000d19, 0x08);
	WriteReg8(0x20000d1a, 0x08);
	WriteReg8(0x20000d1b, 0x0f);
	WriteReg8(0x20000d1c, 0x0f);
	WriteReg8(0x20000d1d, 0x08);
	WriteReg8(0x20000d1e, 0x08);
	WriteReg8(0x20000d1f, 0x08);
	fprintf(setting,"\n");
	WriteReg8(0x20000d20, 0x08);
	WriteReg8(0x20000d21, 0x08);
	WriteReg8(0x20000d22, 0x08);
	WriteReg8(0x20000d23, 0x0c);
	WriteReg8(0x20000d24, 0x0c);
	WriteReg8(0x20000d25, 0x08);
	WriteReg8(0x20000d26, 0x08);
	WriteReg8(0x20000d27, 0x08);
	fprintf(setting,"\n");
	WriteReg8(0x20000d28, 0x06);
	WriteReg8(0x20000d29, 0x06);
	WriteReg8(0x20000d2a, 0x08);
	WriteReg8(0x20000d2b, 0x08);
	WriteReg8(0x20000d2c, 0x06);
	WriteReg8(0x20000d2d, 0x06);
	WriteReg8(0x20000d2e, 0x06);
	WriteReg8(0x20000d2f, 0x06);
	fprintf(setting,"\n");
	WriteReg8(0x20000d30, 0x02);
	WriteReg8(0x20000d31, 0x02);
	WriteReg8(0x20000d32, 0x02);
	WriteReg8(0x20000d33, 0x04);
	WriteReg8(0x20000d34, 0x04);
	WriteReg8(0x20000d35, 0x02);
	WriteReg8(0x20000d36, 0x02);
	WriteReg8(0x20000d37, 0x02);
	
	fprintf(setting,"\n");
	fprintf(setting,"//Gamma_mode\n");
	WriteReg8(0x20000d46, 0x03);
	
	fprintf(setting,"//Rgb_Gamma 0x80301400~1440\n");
	WriteReg8(0x20000d47, 0x00);//day_mode
	WriteReg8(0x20000d48, 0x02);
	WriteReg8(0x20000d49, 0x05);
	WriteReg8(0x20000d4a, 0x08);
	WriteReg8(0x20000d4b, 0x0B);
	WriteReg8(0x20000d4c, 0x0E);
	WriteReg8(0x20000d4d, 0x11);
	WriteReg8(0x20000d4e, 0x14);
	WriteReg8(0x20000d4f, 0x18);
	WriteReg8(0x20000d50, 0x1B);
	WriteReg8(0x20000d51, 0x1E);
	WriteReg8(0x20000d52, 0x21);
	WriteReg8(0x20000d53, 0x24);
	WriteReg8(0x20000d54, 0x27);
	WriteReg8(0x20000d55, 0x2A);
	WriteReg8(0x20000d56, 0x2D);
	WriteReg8(0x20000d57, 0x30);
	WriteReg8(0x20000d58, 0x32);
	WriteReg8(0x20000d59, 0x35);
	WriteReg8(0x20000d5a, 0x38);
	WriteReg8(0x20000d5b, 0x3B);
	WriteReg8(0x20000d5c, 0x3E);
	WriteReg8(0x20000d5d, 0x40);
	WriteReg8(0x20000d5e, 0x43);
	WriteReg8(0x20000d5f, 0x46);
	WriteReg8(0x20000d60, 0x48);
	WriteReg8(0x20000d61, 0x4A);
	WriteReg8(0x20000d62, 0x4D);
	WriteReg8(0x20000d63, 0x4F);
	WriteReg8(0x20000d64, 0x52);
	WriteReg8(0x20000d65, 0x54);
	WriteReg8(0x20000d66, 0x56);
	WriteReg8(0x20000d67, 0x59);
	WriteReg8(0x20000d68, 0x5D);
	WriteReg8(0x20000d69, 0x62);
	WriteReg8(0x20000d6a, 0x66);
	WriteReg8(0x20000d6b, 0x6A);
	WriteReg8(0x20000d6c, 0x6F);
	WriteReg8(0x20000d6d, 0x73);
	WriteReg8(0x20000d6e, 0x77);
	WriteReg8(0x20000d6f, 0x7C);
	WriteReg8(0x20000d70, 0x80);
	WriteReg8(0x20000d71, 0x84);
	WriteReg8(0x20000d72, 0x88);
	WriteReg8(0x20000d73, 0x8B);
	WriteReg8(0x20000d74, 0x8F);
	WriteReg8(0x20000d75, 0x93);
	WriteReg8(0x20000d76, 0x97);
	WriteReg8(0x20000d77, 0x9B);
	WriteReg8(0x20000d78, 0xA2);
	WriteReg8(0x20000d79, 0xA9);
	WriteReg8(0x20000d7a, 0xB0);
	WriteReg8(0x20000d7b, 0xB6);
	WriteReg8(0x20000d7c, 0xBD);
	WriteReg8(0x20000d7d, 0xC3);
	WriteReg8(0x20000d7e, 0xCA);
	WriteReg8(0x20000d7f, 0xD0);
	WriteReg8(0x20000d80, 0xD6);
	WriteReg8(0x20000d81, 0xDC);
	WriteReg8(0x20000d82, 0xE2);
	WriteReg8(0x20000d83, 0xE8);
	WriteReg8(0x20000d84, 0xEE);
	WriteReg8(0x20000d85, 0xF4);
	WriteReg8(0x20000d86, 0xF9);
	WriteReg8(0x20000d87, 0xfe);
	fprintf(setting,"\n");
	WriteReg8(0x20000d88, 0x00);//night_mode
	WriteReg8(0x20000d89, 0x02);
	WriteReg8(0x20000d8a, 0x05);
	WriteReg8(0x20000d8b, 0x08);
	WriteReg8(0x20000d8c, 0x0B);
	WriteReg8(0x20000d8d, 0x0E);
	WriteReg8(0x20000d8e, 0x11);
	WriteReg8(0x20000d8f, 0x14);
	WriteReg8(0x20000d90, 0x18);
	WriteReg8(0x20000d91, 0x1B);
	WriteReg8(0x20000d92, 0x1E);
	WriteReg8(0x20000d93, 0x21);
	WriteReg8(0x20000d94, 0x24);
	WriteReg8(0x20000d95, 0x27);
	WriteReg8(0x20000d96, 0x2A);
	WriteReg8(0x20000d97, 0x2D);
	WriteReg8(0x20000d98, 0x30);
	WriteReg8(0x20000d99, 0x32);
	WriteReg8(0x20000d9a, 0x35);
	WriteReg8(0x20000d9b, 0x38);
	WriteReg8(0x20000d9c, 0x3B);
	WriteReg8(0x20000d9d, 0x3E);
	WriteReg8(0x20000d9e, 0x40);
	WriteReg8(0x20000d9f, 0x43);
	WriteReg8(0x20000da0, 0x46);
	WriteReg8(0x20000da1, 0x48);
	WriteReg8(0x20000da2, 0x4A);
	WriteReg8(0x20000da3, 0x4D);
	WriteReg8(0x20000da4, 0x4F);
	WriteReg8(0x20000da5, 0x52);
	WriteReg8(0x20000da6, 0x54);
	WriteReg8(0x20000da7, 0x56);
	WriteReg8(0x20000da8, 0x59);
	WriteReg8(0x20000da9, 0x5D);
	WriteReg8(0x20000daa, 0x62);
	WriteReg8(0x20000dab, 0x66);
	WriteReg8(0x20000dac, 0x6A);
	WriteReg8(0x20000dad, 0x6F);
	WriteReg8(0x20000dae, 0x73);
	WriteReg8(0x20000daf, 0x77);
	WriteReg8(0x20000db0, 0x7C);
	WriteReg8(0x20000db1, 0x80);
	WriteReg8(0x20000db2, 0x84);
	WriteReg8(0x20000db3, 0x88);
	WriteReg8(0x20000db4, 0x8B);
	WriteReg8(0x20000db5, 0x8F);
	WriteReg8(0x20000db6, 0x93);
	WriteReg8(0x20000db7, 0x97);
	WriteReg8(0x20000db8, 0x9B);
	WriteReg8(0x20000db9, 0xA2);
	WriteReg8(0x20000dba, 0xA9);
	WriteReg8(0x20000dbb, 0xB0);
	WriteReg8(0x20000dbc, 0xB6);
	WriteReg8(0x20000dbd, 0xBD);
	WriteReg8(0x20000dbe, 0xC3);
	WriteReg8(0x20000dbf, 0xCA);
	WriteReg8(0x20000dc0, 0xD0);
	WriteReg8(0x20000dc1, 0xD6);
	WriteReg8(0x20000dc2, 0xDC);
	WriteReg8(0x20000dc3, 0xE2);
	WriteReg8(0x20000dc4, 0xE8);
	WriteReg8(0x20000dc5, 0xEE);
	WriteReg8(0x20000dc6, 0xF4);
	WriteReg8(0x20000dc7, 0xF9);
	WriteReg8(0x20000dc8, 0xfe);
	fprintf(setting,"\n");
	WriteReg8(0x20000dc9, 0x00);//midnight_mode
	WriteReg8(0x20000dca, 0x02);
	WriteReg8(0x20000dcb, 0x05);
	WriteReg8(0x20000dcc, 0x08);
	WriteReg8(0x20000dcd, 0x0B);
	WriteReg8(0x20000dce, 0x0E);
	WriteReg8(0x20000dcf, 0x11);
	WriteReg8(0x20000dd0, 0x14);
	WriteReg8(0x20000dd1, 0x18);
	WriteReg8(0x20000dd2, 0x1B);
	WriteReg8(0x20000dd3, 0x1E);
	WriteReg8(0x20000dd4, 0x21);
	WriteReg8(0x20000dd5, 0x24);
	WriteReg8(0x20000dd6, 0x27);
	WriteReg8(0x20000dd7, 0x2A);
	WriteReg8(0x20000dd8, 0x2D);
	WriteReg8(0x20000dd9, 0x30);
	WriteReg8(0x20000dda, 0x32);
	WriteReg8(0x20000ddb, 0x35);
	WriteReg8(0x20000ddc, 0x38);
	WriteReg8(0x20000ddd, 0x3B);
	WriteReg8(0x20000dde, 0x3E);
	WriteReg8(0x20000ddf, 0x40);
	WriteReg8(0x20000de0, 0x43);
	WriteReg8(0x20000de1, 0x46);
	WriteReg8(0x20000de2, 0x48);
	WriteReg8(0x20000de3, 0x4A);
	WriteReg8(0x20000de4, 0x4D);
	WriteReg8(0x20000de5, 0x4F);
	WriteReg8(0x20000de6, 0x52);
	WriteReg8(0x20000de7, 0x54);
	WriteReg8(0x20000de8, 0x56);
	WriteReg8(0x20000de9, 0x59);
	WriteReg8(0x20000dea, 0x5D);
	WriteReg8(0x20000deb, 0x62);
	WriteReg8(0x20000dec, 0x66);
	WriteReg8(0x20000ded, 0x6A);
	WriteReg8(0x20000dee, 0x6F);
	WriteReg8(0x20000def, 0x73);
	WriteReg8(0x20000df0, 0x77);
	WriteReg8(0x20000df1, 0x7C);
	WriteReg8(0x20000df2, 0x80);
	WriteReg8(0x20000df3, 0x84);
	WriteReg8(0x20000df4, 0x88);
	WriteReg8(0x20000df5, 0x8B);
	WriteReg8(0x20000df6, 0x8F);
	WriteReg8(0x20000df7, 0x93);
	WriteReg8(0x20000df8, 0x97);
	WriteReg8(0x20000df9, 0x9B);
	WriteReg8(0x20000dfa, 0xA2);
	WriteReg8(0x20000dfb, 0xA9);
	WriteReg8(0x20000dfc, 0xB0);
	WriteReg8(0x20000dfd, 0xB6);
	WriteReg8(0x20000dfe, 0xBD);
	WriteReg8(0x20000dff, 0xC3);
	WriteReg8(0x20000e00, 0xCA);
	WriteReg8(0x20000e01, 0xD0);
	WriteReg8(0x20000e02, 0xD6);
	WriteReg8(0x20000e03, 0xDC);
	WriteReg8(0x20000e04, 0xE2);
	WriteReg8(0x20000e05, 0xE8);
	WriteReg8(0x20000e06, 0xEE);
	WriteReg8(0x20000e07, 0xF4);
	WriteReg8(0x20000e08, 0xF9);
	WriteReg8(0x20000e09, 0xfe);
	
	fprintf(setting,"\n");
	fprintf(setting,"//Raw_Gamma 0x80300900~0940\n");
	WriteReg8(0x20000e0a, 0x00);//day_mode
	WriteReg8(0x20000e0b, 0x06);
	WriteReg8(0x20000e0c, 0x0B);
	WriteReg8(0x20000e0d, 0x11);
	WriteReg8(0x20000e0e, 0x17);
	WriteReg8(0x20000e0f, 0x1D);
	WriteReg8(0x20000e10, 0x22);
	WriteReg8(0x20000e11, 0x28);
	WriteReg8(0x20000e12, 0x2D);
	WriteReg8(0x20000e13, 0x31);
	WriteReg8(0x20000e14, 0x36);
	WriteReg8(0x20000e15, 0x3A);
	WriteReg8(0x20000e16, 0x3E);
	WriteReg8(0x20000e17, 0x41);
	WriteReg8(0x20000e18, 0x45);
	WriteReg8(0x20000e19, 0x48);
	WriteReg8(0x20000e1a, 0x4C);
	WriteReg8(0x20000e1b, 0x4F);
	WriteReg8(0x20000e1c, 0x51);
	WriteReg8(0x20000e1d, 0x54);
	WriteReg8(0x20000e1e, 0x57);
	WriteReg8(0x20000e1f, 0x59);
	WriteReg8(0x20000e20, 0x5C);
	WriteReg8(0x20000e21, 0x5E);
	WriteReg8(0x20000e22, 0x61);
	WriteReg8(0x20000e23, 0x63);
	WriteReg8(0x20000e24, 0x65);
	WriteReg8(0x20000e25, 0x67);
	WriteReg8(0x20000e26, 0x69);
	WriteReg8(0x20000e27, 0x6B);
	WriteReg8(0x20000e28, 0x6D);
	WriteReg8(0x20000e29, 0x70);
	WriteReg8(0x20000e2a, 0x72);
	WriteReg8(0x20000e2b, 0x75);
	WriteReg8(0x20000e2c, 0x79);
	WriteReg8(0x20000e2d, 0x7D);
	WriteReg8(0x20000e2e, 0x80);
	WriteReg8(0x20000e2f, 0x84);
	WriteReg8(0x20000e30, 0x87);
	WriteReg8(0x20000e31, 0x8A);
	WriteReg8(0x20000e32, 0x8E);
	WriteReg8(0x20000e33, 0x91);
	WriteReg8(0x20000e34, 0x94);
	WriteReg8(0x20000e35, 0x97);
	WriteReg8(0x20000e36, 0x9A);
	WriteReg8(0x20000e37, 0x9D);
	WriteReg8(0x20000e38, 0xA0);
	WriteReg8(0x20000e39, 0xA3);
	WriteReg8(0x20000e3a, 0xA6);
	WriteReg8(0x20000e3b, 0xAB);
	WriteReg8(0x20000e3c, 0xB1);
	WriteReg8(0x20000e3d, 0xB6);
	WriteReg8(0x20000e3e, 0xBB);
	WriteReg8(0x20000e3f, 0xC0);
	WriteReg8(0x20000e40, 0xC6);
	WriteReg8(0x20000e41, 0xCB);
	WriteReg8(0x20000e42, 0xD1);
	WriteReg8(0x20000e43, 0xD6);
	WriteReg8(0x20000e44, 0xDC);
	WriteReg8(0x20000e45, 0xE2);
	WriteReg8(0x20000e46, 0xE7);
	WriteReg8(0x20000e47, 0xED);
	WriteReg8(0x20000e48, 0xF3);
	WriteReg8(0x20000e49, 0xF9);
	WriteReg8(0x20000e4a, 0xfe);
	fprintf(setting,"\n");
	WriteReg8(0x20000e4b, 0x00);//night_mode
	WriteReg8(0x20000e4c, 0x06);
	WriteReg8(0x20000e4d, 0x0B);
	WriteReg8(0x20000e4e, 0x11);
	WriteReg8(0x20000e4f, 0x17);
	WriteReg8(0x20000e50, 0x1D);
	WriteReg8(0x20000e51, 0x22);
	WriteReg8(0x20000e52, 0x28);
	WriteReg8(0x20000e53, 0x2D);
	WriteReg8(0x20000e54, 0x31);
	WriteReg8(0x20000e55, 0x36);
	WriteReg8(0x20000e56, 0x3A);
	WriteReg8(0x20000e57, 0x3E);
	WriteReg8(0x20000e58, 0x41);
	WriteReg8(0x20000e59, 0x45);
	WriteReg8(0x20000e5a, 0x48);
	WriteReg8(0x20000e5b, 0x4C);
	WriteReg8(0x20000e5c, 0x4F);
	WriteReg8(0x20000e5d, 0x51);
	WriteReg8(0x20000e5e, 0x54);
	WriteReg8(0x20000e5f, 0x57);
	WriteReg8(0x20000e60, 0x59);
	WriteReg8(0x20000e61, 0x5C);
	WriteReg8(0x20000e62, 0x5E);
	WriteReg8(0x20000e63, 0x61);
	WriteReg8(0x20000e64, 0x63);
	WriteReg8(0x20000e65, 0x65);
	WriteReg8(0x20000e66, 0x67);
	WriteReg8(0x20000e67, 0x69);
	WriteReg8(0x20000e68, 0x6B);
	WriteReg8(0x20000e69, 0x6D);
	WriteReg8(0x20000e6a, 0x70);
	WriteReg8(0x20000e6b, 0x72);
	WriteReg8(0x20000e6c, 0x75);
	WriteReg8(0x20000e6d, 0x79);
	WriteReg8(0x20000e6e, 0x7D);
	WriteReg8(0x20000e6f, 0x80);
	WriteReg8(0x20000e70, 0x84);
	WriteReg8(0x20000e71, 0x87);
	WriteReg8(0x20000e72, 0x8A);
	WriteReg8(0x20000e73, 0x8E);
	WriteReg8(0x20000e74, 0x91);
	WriteReg8(0x20000e75, 0x94);
	WriteReg8(0x20000e76, 0x97);
	WriteReg8(0x20000e77, 0x9A);
	WriteReg8(0x20000e78, 0x9D);
	WriteReg8(0x20000e79, 0xA0);
	WriteReg8(0x20000e7a, 0xA3);
	WriteReg8(0x20000e7b, 0xA6);
	WriteReg8(0x20000e7c, 0xAB);
	WriteReg8(0x20000e7d, 0xB1);
	WriteReg8(0x20000e7e, 0xB6);
	WriteReg8(0x20000e7f, 0xBB);
	WriteReg8(0x20000e80, 0xC0);
	WriteReg8(0x20000e81, 0xC6);
	WriteReg8(0x20000e82, 0xCB);
	WriteReg8(0x20000e83, 0xD1);
	WriteReg8(0x20000e84, 0xD6);
	WriteReg8(0x20000e85, 0xDC);
	WriteReg8(0x20000e86, 0xE2);
	WriteReg8(0x20000e87, 0xE7);
	WriteReg8(0x20000e88, 0xED);
	WriteReg8(0x20000e89, 0xF3);
	WriteReg8(0x20000e8a, 0xF9);
	WriteReg8(0x20000e8b, 0xfe);
	fprintf(setting,"\n");
	WriteReg8(0x20000e8c, 0x00);//midnight_mode
	WriteReg8(0x20000e8d, 0x06);
	WriteReg8(0x20000e8e, 0x0B);
	WriteReg8(0x20000e8f, 0x11);
	WriteReg8(0x20000e90, 0x17);
	WriteReg8(0x20000e91, 0x1D);
	WriteReg8(0x20000e92, 0x22);
	WriteReg8(0x20000e93, 0x28);
	WriteReg8(0x20000e94, 0x2D);
	WriteReg8(0x20000e95, 0x31);
	WriteReg8(0x20000e96, 0x36);
	WriteReg8(0x20000e97, 0x3A);
	WriteReg8(0x20000e98, 0x3E);
	WriteReg8(0x20000e99, 0x41);
	WriteReg8(0x20000e9a, 0x45);
	WriteReg8(0x20000e9b, 0x48);
	WriteReg8(0x20000e9c, 0x4C);
	WriteReg8(0x20000e9d, 0x4F);
	WriteReg8(0x20000e9e, 0x51);
	WriteReg8(0x20000e9f, 0x54);
	WriteReg8(0x20000ea0, 0x57);
	WriteReg8(0x20000ea1, 0x59);
	WriteReg8(0x20000ea2, 0x5C);
	WriteReg8(0x20000ea3, 0x5E);
	WriteReg8(0x20000ea4, 0x61);
	WriteReg8(0x20000ea5, 0x63);
	WriteReg8(0x20000ea6, 0x65);
	WriteReg8(0x20000ea7, 0x67);
	WriteReg8(0x20000ea8, 0x69);
	WriteReg8(0x20000ea9, 0x6B);
	WriteReg8(0x20000eaa, 0x6D);
	WriteReg8(0x20000eab, 0x70);
	WriteReg8(0x20000eac, 0x72);
	WriteReg8(0x20000ead, 0x75);
	WriteReg8(0x20000eae, 0x79);
	WriteReg8(0x20000eaf, 0x7D);
	WriteReg8(0x20000eb0, 0x80);
	WriteReg8(0x20000eb1, 0x84);
	WriteReg8(0x20000eb2, 0x87);
	WriteReg8(0x20000eb3, 0x8A);
	WriteReg8(0x20000eb4, 0x8E);
	WriteReg8(0x20000eb5, 0x91);
	WriteReg8(0x20000eb6, 0x94);
	WriteReg8(0x20000eb7, 0x97);
	WriteReg8(0x20000eb8, 0x9A);
	WriteReg8(0x20000eb9, 0x9D);
	WriteReg8(0x20000eba, 0xA0);
	WriteReg8(0x20000ebb, 0xA3);
	WriteReg8(0x20000ebc, 0xA6);
	WriteReg8(0x20000ebd, 0xAB);
	WriteReg8(0x20000ebe, 0xB1);
	WriteReg8(0x20000ebf, 0xB6);
	WriteReg8(0x20000ec0, 0xBB);
	WriteReg8(0x20000ec1, 0xC0);
	WriteReg8(0x20000ec2, 0xC6);
	WriteReg8(0x20000ec3, 0xCB);
	WriteReg8(0x20000ec4, 0xD1);
	WriteReg8(0x20000ec5, 0xD6);
	WriteReg8(0x20000ec6, 0xDC);
	WriteReg8(0x20000ec7, 0xE2);
	WriteReg8(0x20000ec8, 0xE7);
	WriteReg8(0x20000ec9, 0xED);
	WriteReg8(0x20000eca, 0xF3);
	WriteReg8(0x20000ecb, 0xF9);
	WriteReg8(0x20000ecc, 0xfe);
	
	fprintf(setting,"\n");
	fprintf(setting,"//RGB_Gamma_HF 0x80301450/1452/1453\n");
	WriteReg8(0x20000ecd, 0x60);//day_mode
	WriteReg8(0x20000ece, 0x40);
	WriteReg8(0x20000ecf, 0x20);
	WriteReg8(0x20000ed0, 0x60);//night_mode
	WriteReg8(0x20000ed1, 0x40);
	WriteReg8(0x20000ed2, 0x20);
	WriteReg8(0x20000ed3, 0x60);//midnight_mode
	WriteReg8(0x20000ed4, 0x40);
	WriteReg8(0x20000ed5, 0x20);
	
	fprintf(setting,"\n");
	fprintf(setting,"//avg_calc\n");
	WriteReg8(0x20001458, 0x00);//day_mode
	WriteReg8(0x20001459, 0x40);
	WriteReg8(0x2000145a, 0x00);//night_mode
	WriteReg8(0x2000145b, 0x40);
	WriteReg8(0x2000145c, 0x00);//midnight_mode
	WriteReg8(0x2000145d, 0x40);
	
	fprintf(setting,"\n");
	fprintf(setting,"//NR3D_wt 0x80303c01/3c04\n");
	WriteReg8(0x20000fb9, 0x20);//day_mode
	WriteReg8(0x20001020, 0x40);
	WriteReg8(0x20000fba, 0x38);//night_mode
	WriteReg8(0x20001021, 0x40);
	WriteReg8(0x20000fbb, 0x58);//midnight_mode
	WriteReg8(0x20001022, 0x60);
	
	fprintf(setting,"\n");
	fprintf(setting,"//awb_stat_blc 0x8030071b/451b/471b\n");
	WriteReg8(0x20001023, 0x10);//day_mode
	WriteReg8(0x20001024, 0x10);
	WriteReg8(0x20001025, 0x10);
	WriteReg8(0x20001026, 0x10);//night_mode
	WriteReg8(0x20001027, 0x10);
	WriteReg8(0x20001028, 0x10);
	WriteReg8(0x20001029, 0x10);//midnight_mode
	WriteReg8(0x2000102a, 0x10);
	WriteReg8(0x2000102b, 0x10);
	
	fprintf(setting,"\n");
	fprintf(setting,"//cmx 0x80301200~1223/0x1228~1235\n");
	WriteReg8(0x20000fbc, 0x00);//day_mode
	WriteReg8(0x20000fbd, 0x00);
	WriteReg8(0x20000fbe, 0x00);
	WriteReg8(0x20000fbf, 0x00);
	WriteReg8(0x20000fc0, 0x00);
	WriteReg8(0x20000fc1, 0x63);
	WriteReg8(0x20000fc2, 0x01);
	WriteReg8(0x20000fc3, 0x64);
	WriteReg8(0x20000fc4, 0x00);
	WriteReg8(0x20000fc5, 0x65);
	WriteReg8(0x20000fc6, 0x01);
	WriteReg8(0x20000fc7, 0x99);
	WriteReg8(0x20000fc8, 0x00);
	WriteReg8(0x20000fc9, 0x0a);
	WriteReg8(0x20000fca, 0x00);
	WriteReg8(0x20000fcb, 0x82);
	WriteReg8(0x20000fcc, 0x00);
	WriteReg8(0x20000fcd, 0xea);
	WriteReg8(0x20000fce, 0x01);
	WriteReg8(0x20000fcf, 0xac);
	WriteReg8(0x20000fd0, 0x00);
	WriteReg8(0x20000fd1, 0x82);
	WriteReg8(0x20000fd2, 0x03);
	WriteReg8(0x20000fd3, 0x5e);
	WriteReg8(0x20000fd4, 0x00);
	WriteReg8(0x20000fd5, 0x74);
	WriteReg8(0x20000fd6, 0x00);
	WriteReg8(0x20000fd7, 0x5d);
	WriteReg8(0x20000fd8, 0x01);
	WriteReg8(0x20000fd9, 0x28);
	WriteReg8(0x20000fda, 0x01);
	WriteReg8(0x20000fdb, 0xef);
	WriteReg8(0x20000fdc, 0x00);
	WriteReg8(0x20000fdd, 0xa7);
	WriteReg8(0x20000fde, 0x04);
	WriteReg8(0x20000fdf, 0x37);
	fprintf(setting,"\n");
	WriteReg8(0x20000fe0, 0x00);//cmx_ct_list
	WriteReg8(0x20000fe1, 0x80);
	WriteReg8(0x20000fe2, 0x00);
	WriteReg8(0x20000fe3, 0xc0);
	WriteReg8(0x20000fe4, 0x01);
	WriteReg8(0x20000fe5, 0x20);
	fprintf(setting,"\n");
	WriteReg8(0x20000fe6, 0x00);//sign
	WriteReg8(0x20000fe7, 0x00);
	WriteReg8(0x20000fe8, 0x00);
	fprintf(setting,"\n");
	WriteReg8(0x20000fe9, 0x03);//cmx_ctrl_day
	WriteReg8(0x20000fea, 0x44);
	WriteReg8(0x20000feb, 0x38);
	WriteReg8(0x20000fec, 0x01);
	WriteReg8(0x20000fed, 0x1f);
	fprintf(setting,"\n");
	WriteReg8(0x20000fee, 0x00);//night_mode
	WriteReg8(0x20000fef, 0x00);
	WriteReg8(0x20000ff0, 0x00);
	WriteReg8(0x20000ff1, 0x00);
	WriteReg8(0x20000ff2, 0x00);
	WriteReg8(0x20000ff3, 0x63);
	WriteReg8(0x20000ff4, 0x01);
	WriteReg8(0x20000ff5, 0x64);
	WriteReg8(0x20000ff6, 0x00);
	WriteReg8(0x20000ff7, 0x65);
	WriteReg8(0x20000ff8, 0x01);
	WriteReg8(0x20000ff9, 0x99);
	WriteReg8(0x20000ffa, 0x00);
	WriteReg8(0x20000ffb, 0x0a);
	WriteReg8(0x20000ffc, 0x00);
	WriteReg8(0x20000ffd, 0x82);
	WriteReg8(0x20000ffe, 0x00);
	WriteReg8(0x20000fff, 0xea);
	WriteReg8(0x20001000, 0x01);
	WriteReg8(0x20001001, 0xac);
	WriteReg8(0x20001002, 0x00);
	WriteReg8(0x20001003, 0x82);
	WriteReg8(0x20001004, 0x03);
	WriteReg8(0x20001005, 0x5e);
	WriteReg8(0x20001006, 0x00);
	WriteReg8(0x20001007, 0x74);
	WriteReg8(0x20001008, 0x00);
	WriteReg8(0x20001009, 0x5d);
	WriteReg8(0x2000100a, 0x01);
	WriteReg8(0x2000100b, 0x28);
	WriteReg8(0x2000100c, 0x01);
	WriteReg8(0x2000100d, 0xef);
	WriteReg8(0x2000100e, 0x00);
	WriteReg8(0x2000100f, 0xa7);
	WriteReg8(0x20001010, 0x04);
	WriteReg8(0x20001011, 0x37);
	fprintf(setting,"\n");
	WriteReg8(0x20001012, 0x00);//cmx_ct_list
	WriteReg8(0x20001013, 0x80);
	WriteReg8(0x20001014, 0x00);
	WriteReg8(0x20001015, 0xc0);
	WriteReg8(0x20001016, 0x01);
	WriteReg8(0x20001017, 0x20);
	fprintf(setting,"\n");
	WriteReg8(0x20001018, 0x00);//sign
	WriteReg8(0x20001019, 0x00);
	WriteReg8(0x2000101a, 0x00);
	fprintf(setting,"\n");
	WriteReg8(0x2000101b, 0x03);//cmx_ctrl_night
	WriteReg8(0x2000101c, 0x44);
	WriteReg8(0x2000101d, 0x38);
	WriteReg8(0x2000101e, 0x01);
	WriteReg8(0x2000101f, 0x1f);
	
	fprintf(setting,"\n");
	fprintf(setting,"//cip_noise 0x80300500\n");
	WriteReg8(0x20000b9f, 0x04);//cip_noise_color
	WriteReg8(0x20000ba0, 0x10);//cip_noise_mono
	
	fprintf(setting,"\n");
	fprintf(setting,"//cip_shp 0x8030050a/050b\n");
	WriteReg8(0x20000ba1, 0x05);//min_shp_color
	WriteReg8(0x20000ba2, 0x10);//max_shp_color
	WriteReg8(0x20000ba3, 0x08);//min_shp_mono
	WriteReg8(0x20000ba4, 0x12);//max_shp_mono
	
	fprintf(setting,"\n");
	fprintf(setting,"//ynr_scale_enh 0x80304a0e~4a16\n");
	WriteReg8(0x20000bb0, 0x30);//color_mode
	WriteReg8(0x20000bb1, 0x28);
	WriteReg8(0x20000bb2, 0x20);
	WriteReg8(0x20000bb3, 0x1a);
	WriteReg8(0x20000bb4, 0x18);
	WriteReg8(0x20000bb5, 0x16);
	WriteReg8(0x20000bb6, 0x14);
	WriteReg8(0x20000bb7, 0x12);
	WriteReg8(0x20000bb8, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bb9, 0x30);//mono_mode
	WriteReg8(0x20000bba, 0x28);
	WriteReg8(0x20000bbb, 0x20);
	WriteReg8(0x20000bbc, 0x1a);
	WriteReg8(0x20000bbd, 0x18);
	WriteReg8(0x20000bbe, 0x16);
	WriteReg8(0x20000bbf, 0x14);
	WriteReg8(0x20000bc0, 0x12);
	WriteReg8(0x20000bc1, 0x10);
	
	fprintf(setting,"\n");
	fprintf(setting,"//contrast 0x80301704\n");
	WriteReg8(0x20000bc2, 0x20);//color_mode
	WriteReg8(0x20000bc3, 0x20);
	WriteReg8(0x20000bc4, 0x20);
	WriteReg8(0x20000bc5, 0x20);
	WriteReg8(0x20000bc6, 0x20);
	WriteReg8(0x20000bc7, 0x20);
	WriteReg8(0x20000bc8, 0x20);
	WriteReg8(0x20000bc9, 0x20);
	WriteReg8(0x20000bca, 0x20);
	fprintf(setting,"\n");
	WriteReg8(0x20000bcb, 0x20);//mono_mode
	WriteReg8(0x20000bcc, 0x20);
	WriteReg8(0x20000bcd, 0x20);
	WriteReg8(0x20000bce, 0x20);
	WriteReg8(0x20000bcf, 0x20);
	WriteReg8(0x20000bd0, 0x20);
	WriteReg8(0x20000bd1, 0x20);
	WriteReg8(0x20000bd2, 0x20);
	WriteReg8(0x20000bd3, 0x20);
	
	fprintf(setting,"\n");
	fprintf(setting,"//ybright 0x80301707\n");
	WriteReg8(0x20000c28, 0x00);//color_mode
	WriteReg8(0x20000c29, 0x00);
	WriteReg8(0x20000c2a, 0x00);
	WriteReg8(0x20000c2b, 0x00);
	WriteReg8(0x20000c2c, 0x00);
	WriteReg8(0x20000c2d, 0x00);
	WriteReg8(0x20000c2e, 0x00);
	WriteReg8(0x20000c2f, 0x00);
	WriteReg8(0x20000c30, 0x00);
	fprintf(setting,"\n");
	WriteReg8(0x20000c31, 0x00);//mono_mode
	WriteReg8(0x20000c32, 0x00);
	WriteReg8(0x20000c33, 0x00);
	WriteReg8(0x20000c34, 0x00);
	WriteReg8(0x20000c35, 0x00);
	WriteReg8(0x20000c36, 0x00);
	WriteReg8(0x20000c37, 0x00);
	WriteReg8(0x20000c38, 0x00);
	WriteReg8(0x20000c39, 0x00);
	
	fprintf(setting,"\n");
	fprintf(setting,"//Target_judge_thr_color\n");
	WriteReg8(0x20000ee4, 0x0e);
	WriteReg8(0x20000ee5, 0x00);
	WriteReg8(0x20000ee6, 0x00);
	WriteReg8(0x20000ee7, 0x00);//target_judge_thr_0
	WriteReg8(0x20000ee8, 0x60);
	WriteReg8(0x20000ee9, 0x00);
	WriteReg8(0x20000eea, 0x00);
	WriteReg8(0x20000eeb, 0x00);//target_judge_thr_1
	WriteReg8(0x20000eec, 0xf0);
	WriteReg8(0x20000eed, 0x00);
	WriteReg8(0x20000eee, 0x00);
	WriteReg8(0x20000eef, 0x00);//target_judge_thr_2
	WriteReg8(0x20000ef0, 0x00);
	WriteReg8(0x20000ef1, 0x02);
	WriteReg8(0x20000ef2, 0x00);
	WriteReg8(0x20000ef3, 0x00);//target_judge_thr_3
	WriteReg8(0x20000ef4, 0x90);
	WriteReg8(0x20000ef5, 0x03);
	WriteReg8(0x20000ef6, 0x00);
	WriteReg8(0x20000ef7, 0x00);//target_judge_thr_4
	
	fprintf(setting,"\n");
	fprintf(setting,"//Target_judge_thr_mono\n");
	WriteReg8(0x20000ef8, 0x0e);
	WriteReg8(0x20000ef9, 0x00);
	WriteReg8(0x20000efa, 0x00);
	WriteReg8(0x20000efb, 0x00);//target_judge_thr_0
	WriteReg8(0x20000efc, 0x60);
	WriteReg8(0x20000efd, 0x00);
	WriteReg8(0x20000efe, 0x00);
	WriteReg8(0x20000eff, 0x00);//target_judge_thr_1
	WriteReg8(0x20000f00, 0xf0);
	WriteReg8(0x20000f01, 0x00);
	WriteReg8(0x20000f02, 0x00);
	WriteReg8(0x20000f03, 0x00);//target_judge_thr_2
	WriteReg8(0x20000f04, 0x00);
	WriteReg8(0x20000f05, 0x02);
	WriteReg8(0x20000f06, 0x00);
	WriteReg8(0x20000f07, 0x00);//target_judge_thr_3
	WriteReg8(0x20000f08, 0x90);
	WriteReg8(0x20000f09, 0x03);
	WriteReg8(0x20000f0a, 0x00);
	WriteReg8(0x20000f0b, 0x00);//target_judge_thr_4
	
	fprintf(setting,"\n");
	fprintf(setting,"//Target_table_color\n");
	WriteReg8(0x20000f0c, 0x80);
	WriteReg8(0x20000f0d, 0x00);//target_table_0
	WriteReg8(0x20000f0e, 0x98);
	WriteReg8(0x20000f0f, 0x00);//target_table_1
	WriteReg8(0x20000f10, 0xa0);
	WriteReg8(0x20000f11, 0x00);//target_table_2
	WriteReg8(0x20000f12, 0xc0);
	WriteReg8(0x20000f13, 0x00);//target_table_3
	WriteReg8(0x20000f14, 0xd0);
	WriteReg8(0x20000f15, 0x00);//target_table_4
	WriteReg8(0x20000f16, 0xe0);
	WriteReg8(0x20000f17, 0x00);//target_table_5
	
	fprintf(setting,"\n");
	fprintf(setting,"//Target_table_mono\n");
	WriteReg8(0x20000f18, 0x80);
	WriteReg8(0x20000f19, 0x00);//target_table_0
	WriteReg8(0x20000f1a, 0x98);
	WriteReg8(0x20000f1b, 0x00);//target_table_1
	WriteReg8(0x20000f1c, 0xa0);
	WriteReg8(0x20000f1d, 0x00);//target_table_2
	WriteReg8(0x20000f1e, 0xc0);
	WriteReg8(0x20000f1f, 0x00);//target_table_3
	WriteReg8(0x20000f20, 0xd0);
	WriteReg8(0x20000f21, 0x00);//target_table_4
	WriteReg8(0x20000f22, 0xe0);
	WriteReg8(0x20000f23, 0x00);//target_table_5
	fprintf(setting,"\n");
	WriteReg8(0x20000f24, 0x00);
	WriteReg8(0x20000f25, 0x04);
	WriteReg8(0x20000f26, 0x00);
	WriteReg8(0x20000f27, 0x00);//target_cal_factor
	
	fprintf(setting,"\n");
	fprintf(setting,"//sat_u 0x80301701\n");
	WriteReg8(0x20000ba7, 0x60);
	WriteReg8(0x20000ba8, 0x60);
	WriteReg8(0x20000ba9, 0x60);
	WriteReg8(0x20000baa, 0x60);
	WriteReg8(0x20000bab, 0x60);
	WriteReg8(0x20000bac, 0x60);
	WriteReg8(0x20000bad, 0x60);
	WriteReg8(0x20000bae, 0x60);
	WriteReg8(0x20000baf, 0x60);
	
	fprintf(setting,"\n");
	fprintf(setting,"//sat_v 0x80301702\n");
	WriteReg8(0x20000bd4, 0x60);
	WriteReg8(0x20000bd5, 0x60);
	WriteReg8(0x20000bd6, 0x60);
	WriteReg8(0x20000bd7, 0x60);
	WriteReg8(0x20000bd8, 0x60);
	WriteReg8(0x20000bd9, 0x60);
	WriteReg8(0x20000bda, 0x60);
	WriteReg8(0x20000bdb, 0x60);
	WriteReg8(0x20000bdc, 0x60);
	
	fprintf(setting,"\n");
	fprintf(setting,"//isp_blc_sub 0x803000a0~00a3\n");
	WriteReg8(0x20000be0, 0x10);
	WriteReg8(0x20000be1, 0x10);
	WriteReg8(0x20000be2, 0x10);
	WriteReg8(0x20000be3, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000be4, 0x10);
	WriteReg8(0x20000be5, 0x10);
	WriteReg8(0x20000be6, 0x10);
	WriteReg8(0x20000be7, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000be8, 0x10);
	WriteReg8(0x20000be9, 0x10);
	WriteReg8(0x20000bea, 0x10);
	WriteReg8(0x20000beb, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bec, 0x10);
	WriteReg8(0x20000bed, 0x10);
	WriteReg8(0x20000bee, 0x10);
	WriteReg8(0x20000bef, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bf0, 0x10);
	WriteReg8(0x20000bf1, 0x10);
	WriteReg8(0x20000bf2, 0x10);
	WriteReg8(0x20000bf3, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bf4, 0x10);
	WriteReg8(0x20000bf5, 0x10);
	WriteReg8(0x20000bf6, 0x10);
	WriteReg8(0x20000bf7, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bf8, 0x10);
	WriteReg8(0x20000bf9, 0x10);
	WriteReg8(0x20000bfa, 0x10);
	WriteReg8(0x20000bfb, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000bfc, 0x10);
	WriteReg8(0x20000bfd, 0x10);
	WriteReg8(0x20000bfe, 0x10);
	WriteReg8(0x20000bff, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c00, 0x10);
	WriteReg8(0x20000c01, 0x10);
	WriteReg8(0x20000c02, 0x10);
	WriteReg8(0x20000c03, 0x10);
	
	fprintf(setting,"\n");
	fprintf(setting,"//isp_blc_add 0x803000b4~00b7\n");
	WriteReg8(0x20000c04, 0x10);
	WriteReg8(0x20000c05, 0x10);
	WriteReg8(0x20000c06, 0x10);
	WriteReg8(0x20000c07, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c08, 0x10);
	WriteReg8(0x20000c09, 0x10);
	WriteReg8(0x20000c0a, 0x10);
	WriteReg8(0x20000c0b, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c0c, 0x10);
	WriteReg8(0x20000c0d, 0x10);
	WriteReg8(0x20000c0e, 0x10);
	WriteReg8(0x20000c0f, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c10, 0x10);
	WriteReg8(0x20000c11, 0x10);
	WriteReg8(0x20000c12, 0x10);
	WriteReg8(0x20000c13, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c14, 0x10);
	WriteReg8(0x20000c15, 0x10);
	WriteReg8(0x20000c16, 0x10);
	WriteReg8(0x20000c17, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c18, 0x10);
	WriteReg8(0x20000c19, 0x10);
	WriteReg8(0x20000c1a, 0x10);
	WriteReg8(0x20000c1b, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c1c, 0x10);
	WriteReg8(0x20000c1d, 0x10);
	WriteReg8(0x20000c1e, 0x10);
	WriteReg8(0x20000c1f, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c20, 0x10);
	WriteReg8(0x20000c21, 0x10);
	WriteReg8(0x20000c22, 0x10);
	WriteReg8(0x20000c23, 0x10);
	fprintf(setting,"\n");
	WriteReg8(0x20000c24, 0x10);
	WriteReg8(0x20000c25, 0x10);
	WriteReg8(0x20000c26, 0x10);
	WriteReg8(0x20000c27, 0x10);
	
	fprintf(setting,"\n");
	fprintf(setting,"//snr_blc_value\n");
	WriteReg8(0x20000c3c, 0x10);
	WriteReg8(0x20000c3d, 0x10);
	WriteReg8(0x20000c3e, 0x10);
	WriteReg8(0x20000c3f, 0x10);
	WriteReg8(0x20000c40, 0x10);
	WriteReg8(0x20000c41, 0x10);
	WriteReg8(0x20000c42, 0x10);
	WriteReg8(0x20000c43, 0x10);
	WriteReg8(0x20000c44, 0x10);
	WriteReg8(0x20000c45, 0x10);
	WriteReg8(0x20000c46, 0x10);
	WriteReg8(0x20000c47, 0x10);
	WriteReg8(0x20000c48, 0x10);
	WriteReg8(0x20000c49, 0x10);
	WriteReg8(0x20000c4a, 0x10);
	WriteReg8(0x20000c4b, 0x10);
	WriteReg8(0x20000c4c, 0x10);
	WriteReg8(0x20000c4d, 0x10);
	WriteReg8(0x20000c4e, 0x10);
	WriteReg8(0x20000c4f, 0x10);
	WriteReg8(0x20000c50, 0x10);
	WriteReg8(0x20000c51, 0x10);
	WriteReg8(0x20000c52, 0x10);
	WriteReg8(0x20000c53, 0x10);
	WriteReg8(0x20000c54, 0x10);
	WriteReg8(0x20000c55, 0x10);
	WriteReg8(0x20000c56, 0x10);
	WriteReg8(0x20000c57, 0x10);
	WriteReg8(0x20000c58, 0x10);
	WriteReg8(0x20000c59, 0x10);
	WriteReg8(0x20000c5a, 0x10);
	WriteReg8(0x20000c5b, 0x10);
	WriteReg8(0x20000c5c, 0x10);
	WriteReg8(0x20000c5d, 0x10);
	WriteReg8(0x20000c5e, 0x10);
	WriteReg8(0x20000c5f, 0x10);
	
	fprintf(setting,"\n");
	fprintf(setting,"//adjust_offset\n");
	WriteReg8(0x200017a9, 0x00);//ynr_scale_enhance_min
	WriteReg8(0x200017aa, 0x80);//ynr_scale_enhance_max
	WriteReg8(0x200017dd, 0x00);//ynr_scale_enhance_adjust_offset
	fprintf(setting,"\n");
	WriteReg8(0x2000179f, 0x04);//contrast_min
	WriteReg8(0x200017a0, 0x80);//contrast_max
	WriteReg8(0x200017e1, 0x00);//contrast_adjust_offset
	fprintf(setting,"\n");
	WriteReg8(0x2000179a, 0x00);//luma_min
	WriteReg8(0x2000179b, 0x00);
	WriteReg8(0x2000179c, 0xff);//luma_max
	WriteReg8(0x2000179d, 0x03);
	fprintf(setting,"\n");
	WriteReg8(0x200017e3, 0x00);//target_adjust_offset
	WriteReg8(0x200017df, 0x00);//sat_adjust_offset
	
	fprintf(setting,"\n");
	fprintf(setting,"//IQswitch_enable\n");
	WriteReg8(0x20000b90, 0x07);//switch_mode
	WriteReg8(0x20000b92, snr_blc_mode);//sensor_blc_en
	WriteReg8(0x20000b93, snr_blc_page_value);//sensor_page_val
	WriteReg8(0x20000b94, snr_blc_page_addr&0xff);
	WriteReg8(0x20000b95, (snr_blc_page_addr>>8)&0xff);//sensor_page_addr
	WriteReg8(0x20000b9e, snr_blc_channel_num);//snr_blc_ch_num
	fprintf(setting,"\n");
	WriteReg8(0x20000b96, snr_blc_addr[0]&0xff);//snr_blc_addr
	WriteReg8(0x20000b97, (snr_blc_addr[0]>>8)&0xff);
	WriteReg8(0x20000b98, snr_blc_addr[1]&0xff);
	WriteReg8(0x20000b99, (snr_blc_addr[1]>>8)&0xff);
	WriteReg8(0x20000b9a, snr_blc_addr[2]&0xff);
	WriteReg8(0x20000b9b, (snr_blc_addr[2]>>8)&0xff);
	WriteReg8(0x20000b9c, snr_blc_addr[3]&0xff);
	WriteReg8(0x20000b9d, (snr_blc_addr[3]>>8)&0xff);
	fprintf(setting,"\n");
	WriteReg8(0x20000eda, 0xff);//max_avg_value
	WriteReg8(0x20000edb, 0x03);
	WriteReg8(0x20000ede, 0x0c);//effect_delay
	WriteReg8(0x20000ed6, 0x04);//frame_delay
	fprintf(setting,"\n");
	WriteReg8(0x20000b91, 0x01);//target_switch_mode
	WriteReg8(0x20000040, 0x02);//IQ_switch_en
	WriteReg8(0x20000064, 0x12);//effect_iq_mode
	WriteReg8(0x20000065, 0x12);//effect_scene_mode
	fprintf(setting,"\n");
	WriteReg8(0x2000178a, 0x01);//cip_noise_en
	WriteReg8(0x2000178b, 0x01);//cip_shp_en
	WriteReg8(0x2000178c, 0x01);//ynr_scale_enh_en
	WriteReg8(0x2000178d, 0x01);//saturation_en
	WriteReg8(0x2000178e, 0x01);//contrast_en
	WriteReg8(0x2000178f, 0x01);//ybright_en
	WriteReg8(0x20001790, 0x01);//isp_blc_sub_en
	WriteReg8(0x20001791, 0x01);//isp_blc_add_en
	WriteReg8(0x20001792, 0x01);//cmx_en
	WriteReg8(0x20001793, 0x01);//avg_weight_en
	WriteReg8(0x20001794, 0x01);//nr3d_wt_en
	WriteReg8(0x20001795, 0x01);//awb_stat_blc_en
	WriteReg8(0x20001796, 0x01);//rgb_gamma_hf_en
	WriteReg8(0x20001797, 0x01);//avg_calc_en
	WriteReg8(0x20001798, 0x01);//avg_size_en
	WriteReg8(0x200018b5, 0x01);//isp_blc_sub_mode
	fprintf(setting,"\n");
	WriteReg8(0x200014df, 0x01);//Gamma_Refresh//don't_modify
	WriteReg8(0x2000150c, 0x01);//Gain_Refresh//don't_modify
	WriteReg8(0x2000158d, 0x01);//Mode_Refresh//don't_modify
	WriteReg8(0x200015b1, 0x01);//Scene_Refresh//don't_modify
	
}


///////////////////////////////////////////////////////////////////////////////
//Function : Mjpeg
//Author   : nathan
//Notes    : Mjpeg external coding table
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void Mjpeg_cfg (void)
{
	WriteReg8(0x80280003, 0xb3);//don't_modify
  WriteReg8(0x80280007, 0x90);//don't_modify
  WriteReg8(0x80280010, 0x07);//don't_modify
  WriteReg8(0x80280010, 0x04);//don't_modify
  WriteReg8(0x80280010, 0x04);//don't_modify
  WriteReg8(0x80280010, 0x07);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x12);//don't_modify
  WriteReg8(0x80280010, 0x16);//don't_modify
  WriteReg8(0x80280010, 0x1B);//don't_modify
  WriteReg8(0x80280010, 0x05);//don't_modify
  WriteReg8(0x80280010, 0x05);//don't_modify
  WriteReg8(0x80280010, 0x06);//don't_modify
  WriteReg8(0x80280010, 0x08);//don't_modify
  WriteReg8(0x80280010, 0x0C);//don't_modify
  WriteReg8(0x80280010, 0x1A);//don't_modify
  WriteReg8(0x80280010, 0x1B);//don't_modify
  WriteReg8(0x80280010, 0x18);//don't_modify
  WriteReg8(0x80280010, 0x06);//don't_modify
  WriteReg8(0x80280010, 0x06);//don't_modify
  WriteReg8(0x80280010, 0x07);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x12);//don't_modify
  WriteReg8(0x80280010, 0x19);//don't_modify
  WriteReg8(0x80280010, 0x1F);//don't_modify
  WriteReg8(0x80280010, 0x19);//don't_modify
  WriteReg8(0x80280010, 0x06);//don't_modify
  WriteReg8(0x80280010, 0x07);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x0D);//don't_modify
  WriteReg8(0x80280010, 0x16);//don't_modify
  WriteReg8(0x80280010, 0x27);//don't_modify
  WriteReg8(0x80280010, 0x24);//don't_modify
  WriteReg8(0x80280010, 0x1C);//don't_modify
  WriteReg8(0x80280010, 0x08);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x10);//don't_modify
  WriteReg8(0x80280010, 0x19);//don't_modify
  WriteReg8(0x80280010, 0x1E);//don't_modify
  WriteReg8(0x80280010, 0x31);//don't_modify
  WriteReg8(0x80280010, 0x2E);//don't_modify
  WriteReg8(0x80280010, 0x22);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x0F);//don't_modify
  WriteReg8(0x80280010, 0x18);//don't_modify
  WriteReg8(0x80280010, 0x1C);//don't_modify
  WriteReg8(0x80280010, 0x24);//don't_modify
  WriteReg8(0x80280010, 0x2E);//don't_modify
  WriteReg8(0x80280010, 0x33);//don't_modify
  WriteReg8(0x80280010, 0x29);//don't_modify
  WriteReg8(0x80280010, 0x16);//don't_modify
  WriteReg8(0x80280010, 0x1C);//don't_modify
  WriteReg8(0x80280010, 0x23);//don't_modify
  WriteReg8(0x80280010, 0x27);//don't_modify
  WriteReg8(0x80280010, 0x2E);//don't_modify
  WriteReg8(0x80280010, 0x36);//don't_modify
  WriteReg8(0x80280010, 0x36);//don't_modify
  WriteReg8(0x80280010, 0x2D);//don't_modify
  WriteReg8(0x80280010, 0x20);//don't_modify
  WriteReg8(0x80280010, 0x29);//don't_modify
  WriteReg8(0x80280010, 0x29);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x32);//don't_modify
  WriteReg8(0x80280010, 0x2D);//don't_modify
  WriteReg8(0x80280010, 0x2E);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x07);//don't_modify
  WriteReg8(0x80280010, 0x08);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x15);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x08);//don't_modify
  WriteReg8(0x80280010, 0x09);//don't_modify
  WriteReg8(0x80280010, 0x0C);//don't_modify
  WriteReg8(0x80280010, 0x1E);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x0A);//don't_modify
  WriteReg8(0x80280010, 0x0C);//don't_modify
  WriteReg8(0x80280010, 0x19);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x15);//don't_modify
  WriteReg8(0x80280010, 0x1E);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  WriteReg8(0x80280010, 0x2C);//don't_modify
  
}

///////////////////////////////////////////////////////////////////////////////
//Function : Manual 3A
//Author   : liwanyou
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void Manual_3A_cfg (unsigned short Cofficient_self, unsigned short HTS_addr[2],unsigned short VTS_addr[2],unsigned int SENSOR_PCLK)
{
	WriteReg8(0x20000270, Cofficient_self);//Cofficient_self
	
	WriteReg8(0x200002c6, VTS_addr[0]&0xff);
	WriteReg8(0x200002c7, (VTS_addr[0]>>8)&0xff);
	WriteReg8(0x20000296, VTS_addr[1]&0xff);
	WriteReg8(0x20000297, (VTS_addr[1]>>8)&0xff);

	WriteReg8(0x2000031e, HTS_addr[0]&0xff);
	WriteReg8(0x2000031f, (VTS_addr[0]>>8)&0xff);
	WriteReg8(0x200002de, HTS_addr[1]&0xff);
	WriteReg8(0x200002df, (HTS_addr[1]>>8)&0xff);

	WriteReg8(0x2000042c, SENSOR_PCLK&0xff);
	WriteReg8(0x2000042d, (SENSOR_PCLK>>8)&0xff);
	WriteReg8(0x2000042e, (SENSOR_PCLK>>16)&0xff);
	WriteReg8(0x2000042f, (SENSOR_PCLK>>24)&0xff);	
}

///////////////////////////////////////////////////////////////////////////////
//Function : Top_enable
//Author   : nathan
//Notes    :
//Updata   :
///////////////////////////////////////////////////////////////////////////////
void Top_enable_cfg (unsigned char hdr_mode, int isp_scale_sel, int nr3d_enable, int afc_enable)
{
	WriteReg8(0x20000034, 0x01);//AE_enable
	if (hdr_mode ==2) {
		WriteReg8(0x20000035, 0x03);//AWB_enable bit[0]:longExp_en bit[1]:shortExp_en bit[2]:veryshortExp_en
	}
	else if (hdr_mode ==3) {
		WriteReg8(0x20000035, 0x07);//AWB_enable bit[0]:longExp_en bit[1]:shortExp_en bit[2]:veryshortExp_en		
	}
	else{
		WriteReg8(0x20000035, 0x01);//AWB_enable bit[0]:longExp_en bit[1]:shortExp_en bit[2]:veryshortExp_en
	}
	WriteReg8(0x20000036, 0x01);//Lenc_enable
	WriteReg8(0x20000037, afc_enable&0xff);//AF_enable
	WriteReg8(0x20000540, 0x01);//LencMode
	WriteReg8(0x20000541, 0x01);//OnLineMode
	
	fprintf(setting,"\n");
	if (afc_enable ==0) {
		WriteReg8(0x80300000, 0x67);//bit[6]:rgb_gamma_en;bit[5]:raw_gamma_en;bit[4]:afc_en;bit[2]:bc_en;bit[1]:wc_en;bit[0]:cfa_en
	}
	else {
		WriteReg8(0x80300000, 0x77);//bit[6]:rgb_gamma_en;bit[5]:raw_gamma_en;bit[4]:afc_en;bit[2]:bc_en;bit[1]:wc_en;bit[0]:cfa_en		
	}
	//if (isp_scale_sel ==0) {
	//	WriteReg8(0x80300001, 0xa6);//bit[7]:sde_en;bit[5]:dgain_en;bit[4]:scale_en;bit[2]:ynr_en;bit[1]:cmx_en
	//}
	//else {
		WriteReg8(0x80300001, 0xb6);//bit[7]:sde_en;bit[5]:dgain_en;bit[4]:scale_en;bit[2]:ynr_en;bit[1]:cmx_en
	//}
	if (nr3d_enable ==0) {
		WriteReg8(0x80300002, 0x12);//bit[7]:lenc_en;bit[4]:rgb2yuv_en; bit[3]:nr3d_en;bit[1]:snr_en;bit[0]:ygamma_clk_en
	}
	else {
		WriteReg8(0x80300002, 0x1a);//bit[7]:lenc_en;bit[4]:rgb2yuv_en; bit[3]:nr3d_en;bit[1]:snr_en;bit[0]:ygamma_clk_en
	}
	if (hdr_mode ==0) {
		WriteReg8(0x80300003, 0x11);//bit[6]:dcbl;bit[4]:awb_ct_en;bit[3]:ygamma_en;bit[1]:hdr_en;bit[0]:awb_gain_en
	}
	else {
		WriteReg8(0x80300003, 0x13);//bit[6]:dcbl;bit[4]:awb_ct_en;bit[3]:ygamma_en;bit[1]:hdr_en;bit[0]:awb_gain_en		
	}
	WriteReg8(0x80300004, 0x11);//bit[7]:isp_osd1_en;bit[6]:isp_osd2_en;bit[5]:isp_osd3_en;bit[4]:sel_yuv;bit[2]:car_back_line_en;bit[1:0]:cip_sel:0:cip22 1:cip10
	WriteReg8(0x80300005, 0x01);//bit[7:6]:exposure_channel_sel;bit[5]:emb_data_en;bit[2]:mtd_yuv_en;bit[1]:mtd_raw_en;bit[0]:chroma_adj_en
	
	fprintf(setting,"\n");
	WriteReg8(0x80300019, 0x09);
	WriteReg8(0x8030071c, 0x0a);
	WriteReg8(0x8030451c, 0x0a);
	fprintf(setting,"\n");
	fprintf(setting,"//stream_on\n");
	WriteReg8(0x80260005, 0x0f);//bit[3:0]mrx_lane_enable
	fprintf(setting,"\n");
	fprintf(setting,"//TVE_stream_on\n");
	WriteReg8(0x200014b1, 0x0a);//delay_frame
	WriteReg8(0x200014b2, 0x01);//
	WriteReg8(0x200014b5, 0x01);//
}